SitePoint Sponsor

User Tag List

Results 1 to 25 of 25
  1. #1
    SitePoint Enthusiast Anders N's Avatar
    Join Date
    Dec 2004
    Location
    Norway
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with Cutenews

    Hi.
    Since the Cutenews forum is down, i can't think of another place than sitepoint to post this.

    Can i include news from different cutenews installations on one page? If i just use two include codes, i get the following error:
    Fatal error: Cannot redeclare formatsize() (previously declared in /usr/home/web/wno32422/bakgrunner/inc/functions.inc.php:15) in /usr/home/web/wno32422/ringetoner/inc/functions.inc.php on line 15
    Is there any way to come around this?
    You can see the problems for yourself on http://mobilmoro.net/index2.php

    Please move this if it is in the wrong place!

  2. #2
    Free Geek computerages's Avatar
    Join Date
    Oct 2004
    Location
    /dev/null
    Posts
    1,071
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Could you please post the line number 15 of ringetoner/inc/functions.inc.php or the entrie file?

  3. #3
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i think you can use include_once() if both function are same or else try changin the names of the functions
    it means if a function is already included then don't include. so, it include one function only once per page.

  4. #4
    SitePoint Enthusiast Anders N's Avatar
    Join Date
    Dec 2004
    Location
    Norway
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, jaswinder_rana, but i didn't understand. I really dont know anything about php. I tried changing include() with include_once() on both, but didnt get any result. Where should I put it? These are my includes:
    PHP Code:
    <?PHP
        $number 
    4;
        
    $template 'siste';
        
    $PHP_SELF 'bakgrunneropen.php';
        include(
    "bakgrunner/show_news.php");
    ?>
    and
    PHP Code:
    <?PHP
     $number 
    "10";
     
    $template "headlinesCOPY";
     
    $PHP_SELF 'ringetoneropen.php';
     
    $sortby "0";
     include(
    "ringetoner/show_news.php");
    ?>
    computerages:
    This is the file:
    PHP Code:
    <?PHP

    if(!$PHP_SELF){
        if(
    $HTTP_POST_VARS)     {extract($HTTP_POST_VARSEXTR_PREFIX_SAME"post_");}
        if(
    $HTTP_GET_VARS)      {extract($HTTP_GET_VARSEXTR_PREFIX_SAME"get_");}
        if(
    $HTTP_COOKIE_VARS)    {extract($HTTP_COOKIE_VARSEXTR_PREFIX_SAME"cookie_");}
        if(
    $HTTP_ENV_VARS)         {extract($HTTP_ENV_VARSEXTR_PREFIX_SAME"env_");}
    }
    if(
    $PHP_SELF == ""){ $PHP_SELF $HTTP_SERVER_VARS["PHP_SELF"]; }

    ///////////////////////////////////////////////////////
    // Function:     formatsize
    // Description: Format the size of given file

    function formatsize($file_size){
        if(
    $file_size >= 1073741824)
            {
    $file_size round($file_size 1073741824 100) / 100 "GB";}
        elseif(
    $file_size >= 1048576)
            {
    $file_size round($file_size 1048576 100) / 100 "MB";}
        elseif(
    $file_size >= 1024)
            {
    $file_size round($file_size 1024 100) / 100 "KB";}
        else{
    $file_size $file_size "b";}
    return 
    $file_size;
    }

    ///////////////////////////////////////////////////////
    // Class:     microTimer
    // Description: calculates the micro time

    class microTimer {
        function 
    start() {
            global 
    $starttime;
            
    $mtime microtime ();
            
    $mtime explode (' '$mtime);
            
    $mtime $mtime[1] + $mtime[0];
            
    $starttime $mtime;
        }
        function 
    stop() {
            global 
    $starttime;
            
    $mtime microtime ();
            
    $mtime explode (' '$mtime);
            
    $mtime $mtime[1] + $mtime[0];
            
    $endtime $mtime;
            
    $totaltime round (($endtime $starttime), 5);
            return 
    $totaltime;
        }
    }

    ///////////////////////////////////////////////////////
    // Function:     check_login
    // Description: Check login information

    function check_login($username$md5_password){
        
    $result FALSE;
        
    $full_member_db file("./data/users.db.php");
        global 
    $member_db;

        foreach(
    $full_member_db as $member_db_line)
        {
            if(!
    eregi("<\?",$member_db_line)){
                
    $member_db explode("|",$member_db_line);
                if(
    strtolower($member_db[2]) == strtolower($username) && $member_db[3] == md5($md5_password))
                {
                    
    $result TRUE;
                    break;
                }
            }
        }
        return 
    $result;
    }

    ///////////////////////////////////////////////////////
    // Function:     cute_query_string
    // Description: Format the Query_String for CuteNews purpuses index.php?

    function cute_query_string($q_string$strips$type="get"){
        foreach(
    $strips as $key){
            
    $strips[$key] = TRUE;
        }
        
    $var_value explode("&"$q_string);

        foreach(
    $var_value as $var_peace){
            
    $parts explode("="$var_peace);
            if(
    $strips[$parts[0]] != TRUE and $parts[0] != ""){
                if(
    $type == "post"){
                    
    $my_q .= "<input type=\"hidden\" name=\"".$parts[0]."\" value=\"".$parts[1]."\" />\n";
                }else{
                    
    $my_q .= "$var_peace&amp;";
                }
            }
        }

    if( 
    substr($my_q, -5) == "&amp;" ){ $my_q substr($my_q0, -5); }

    return 
    $my_q;
    }

    ///////////////////////////////////////////////////////
    // Function:    Flooder
    // Description: Flood Protection Function
    function flooder($ip$comid){
        global 
    $cutepath$config_flood_time;

        
    $old_db file("$cutepath/data/flood.db.php");
        
    $new_db fopen("$cutepath/data/flood.db.php"w);
        
    $result FALSE;
        foreach(
    $old_db as $old_db_line){
            
    $old_db_arr explode("|"$old_db_line);

            if((
    $old_db_arr[0] + $config_flood_time) > time() ){
                
    fwrite($new_db$old_db_line);
                if(
    $old_db_arr[1] == $ip and $old_db_arr[2] == $comid)
                { 
    $result TRUE; }
            }
        }
        
    fclose($new_db);
        return 
    $result;
    }

    ////////////////////////////////////////////////////////
    // Function:     msg
    // Description: Displays message to user

    function msg($type$title$text$back=FALSE){
      
    echoheader($type$title);
      global 
    $lang;
          echo
    "$text";
        if(
    $back){
            echo
    "<br /><br /> <a href=\"$back\">go back</a>";
        }
      
    echofooter();
    exit();
    }

    ////////////////////////////////////////////////////////
    // Function:     echoheader
    // Description: Displays header skin

    function echoheader($image$header_text){
        global 
    $PHP_SELF$is_loged_in$config_skin$skin_header$lang_content_type$skin_menu$skin_prefix$config_version_name$config_version_id;

        if(
    $is_loged_in == TRUE){ $skin_header preg_replace("/{menu}/""$skin_menu""$skin_header"); }
        else { 
    $skin_header preg_replace("/{menu}/"" &nbsp; $config_version_name""$skin_header"); }
        
    $skin_header preg_replace("/{image-name}/""${skin_prefix}${image}"$skin_header);
        
    $skin_header preg_replace("/{header-text}/"$header_text$skin_header);
        
    $skin_header preg_replace("/{content-type}/"$lang_content_type$skin_header);
        
    $skin_header preg_replace("/{copyrights}/""Powered by <a href=\"http://appelsinjuice.org/?vis=cutenews-aj\">$config_version_name v.$config_version_id</a>  2004  ( forked from <a href=\"http://cutephp.com/\">Cutenews</a> by CutePHP )"$skin_header);

        echo 
    $skin_header;
    }

    ////////////////////////////////////////////////////////
    // Function:     echofooter
    // Description: Displays footer skin

    function echofooter(){

        global 
    $PHP_SELF$is_loged_in$config_skin$skin_footer$lang_content_type$skin_menu$skin_prefix$config_version_name$config_version_id;

        if(
    $is_loged_in == TRUE){ $skin_footer preg_replace("/{menu}/""$skin_menu""$skin_footer"); }
        else { 
    $skin_footer preg_replace("/{menu}/"" &nbsp; $config_version_name""$skin_footer"); }

        
    $skin_footer preg_replace("/{image-name}/""${skin_prefix}${image}"$skin_footer);
        
    $skin_footer preg_replace("/{header-text}/"$header_text$skin_footer);
        
    $skin_footer preg_replace("/{content-type}/"$lang_content_type$skin_footer);
        
    $skin_footer preg_replace("/{copyrights}/""Powered by <a href=\"http://appelsinjuice.org/?vis=cutenews-aj\">$config_version_name v.$config_version_id</a>  2004  ( forked from <a href=\"http://cutephp.com/\">Cutenews</a> by CutePHP )"$skin_footer);

        echo 
    $skin_footer;

    }

    ////////////////////////////////////////////////////////
    // Function:     CountComments
    // Description: Count how many comments belong to a specific article

    function CountComments($id$archive FALSE){

        global 
    $cutepath;

        if(
    $cutepath == ""){ $cutepath "."; }
        
    $result "0";
        if(
    $archive){ $all_comments file("$cutepath/data/archives/${archive}.comments.arch"); }
        else{ 
    $all_comments file("$cutepath/data/comments.txt"); }

        foreach(
    $all_comments as $comment_line)
        {
            
    $comment_arr_1 explode("|>|"$comment_line);
            if(
    $comment_arr_1[0] == $id)
            {
                
    $comment_arr_2 explode("||"$comment_arr_1[1]);
                
    $result count($comment_arr_2)-1;

            }
        }

    return 
    $result;
    }

    ////////////////////////////////////////////////////////
    // Function:     insertSmilies
    // Description: insert smilies for adding into news/comments

    function insertSmilies($insert_location$break_location FALSE)
    {
        global 
    $config_http_script_dir$config_smilies;

        
    $smilies explode(","$config_smilies);
        foreach(
    $smilies as $smile)
        {
            
    $i++; $smile trim($smile);

            
    $output .= "<a href=\"javascript:insertext(':$smile:','$insert_location')\"><img style=\"border: 0px;\" alt=\"$smile\" src=\"$config_http_script_dir/data/emoticons/$smile.gif\" /></a>";
            
    $output .= "&nbsp;";
        }
        return 
    $output;
    }

    ////////////////////////////////////////////////////////
    // Function:     replace_comments
    // Description: Replaces comments charactars
    function replace_comment($way$sourse){
        global 
    $config_http_script_dir$config_smilies;

        
    $sourse stripslashes(trim($sourse));

        if(
    $way == "add"){

            
    $find = array(
                        
    #"'\"'",
                        #"'\''",
                        #"'<'", // replaced by KSES plugin
                        #"'>'", // replaced by KSES plugin
                        
    "'\|'",
                        
    "'\n'",
                        
    "'\r'",
                         );
            
    $replace = array(
                        
    #"&quot;",
                        #"'",
                        #"&lt;", // replaced by KSES plugin
                        #"&gt;", // replaced by KSES plugin
                         
    "|",
                        
    "<br />",
                        
    "",
                         );

        }
        elseif(
    $way == "show"){

            
    /* $find = array(
                        "'\[b\](.*?)\[/b\]'i",
                        "'\[i\](.*?)\[/i\]'i",
                        "'\[u\](.*?)\[/u\]'i",
                        "'\[del\](.*?)\[/del\]'i",
                        "'\[link\](.*?)\[/link\]'i",
                        "'\[link=(.*?)\](.*?)\[/link\]'i",
                        "'\[url\](.*?)\[/url\]'i",
                        "'\[url=(.*?)\](.*?)\[/url\]'i",
                        "'\[quote\](.*?)\[/quote\]'",
                         );
            $replace = array(
                        "<strong>\\1</strong>",
                        "<em>\\1</em>",
                        "<span style=\"text-decoration: underline;\">\\1</span>",
                        "<del>\\1</del>",
                        "<a href=\"\\1\">\\1</a>",
                        "<a href=\"\\1\">\\2</a>",
                        "<a href=\"\\1\">\\1</a>",
                        "<a href=\"\\1\">\\2</a>",
                        "<blockquote class=\"cutenews\"><p>\\1</p></blockquote>",
                         ); 
                         */

            
    $smilies_arr explode(","$config_smilies);
            foreach(
    $smilies_arr as $smile){
                
    $smile trim($smile);
                
    $find[] = "':$smile:'";
                
    $replace[] = "<img style=\"border: 0px;\" alt=\"$smile\" src=\"$config_http_script_dir/data/emoticons/$smile.gif\" />";
            }

        }

    $sourse  preg_replace($find,$replace,$sourse);
    return 
    $sourse;




    ////////////////////////////////////////////////////////
    // Function:     replace_news
    // Description: Replaces news charactars

    function replace_news($way$sourse$replce_n_to_br=TRUE$use_html=TRUE){
        global 
    $config_allow_html_in_news$config_allow_html_in_comments$config_http_script_dir$config_smilies;
        
    $sourse stripslashes($sourse);

        if(
    $way == "show")
        {
            
    $find= array(

    /* 1 */                  "'\[upimage=([^\]]*?) ([^\]]*?)\]'i",
    /* 2 */                    "'\[upimage=(.*?)\]'i",
    /* 3 */                    "'\[b\](.*?)\[/b\]'i",
    /* 4 */                    "'\[i\](.*?)\[/i\]'i",
    /* 5 */                    "'\[u\](.*?)\[/u\]'i",
    /* 6 */                    "'\[link\](.*?)\[/link\]'i",
    /* 7 */                    "'\[color=(.*?)\](.*?)\[/color\]'i",
    /* 8 */                    "'\[size=(.*?)\](.*?)\[/size\]'i",
    /* 9 */                    "'\[font=(.*?)\](.*?)\[/font\]'i",
    /* 10 */                 "'\[align=(.*?)\](.*?)\[/align\]'i",
    /* 12 */                 "'\[image=(.*?)\]'i",
    /* 13 */                 "'\[link=(.*?)\](.*?)\[/link\]'i",

    /* 14 */                "'\[quote=(.*?)\](.*?)\[/quote\]'i",
    /* 15 */                "'\[quote\](.*?)\[/quote\]'i",

    /* 16 */                "'\[list\]'i",
    /* 17 */                "'\[/list\]'i",
    /* 18 */                "'\[\*\]'i",
                            
    "'{nl}'",
                           );

            
    $replace=array(

    /* 1 */                    "<img \\2 src=\"${config_http_script_dir}/skins/images/upskins/images/\\1\" style=\"border: none;\" alt=\"\" />",
    /* 2 */                    "<img src=\"${config_http_script_dir}/skins/images/upskins/images/\\1\" style=\"border: none;\" alt=\"\" />",
    /* 3 */                    "<strong>\\1</strong>",
    /* 4 */                    "<em>\\1</em>",
    /* 5 */                    "<span style=\"text-decoration: underline;\">\\1</span>",
    /* 6 */                    "<a href=\"\\1\">\\1</a>",
    /* 7 */                    "<span style=\"color: \\1;\">\\2</span>",
    /* 8 */                    "<span style=\"font-size: \\1pt;\">\\2</span>",
    /* 9 */                    "<span style=\"font-family: \\1;\">\\2</span>",
    /* 10 */                "<div style=\"text-align: \\1;\">\\2</div>",
    /* 12 */                "<img src=\"\\1\" style=\"border: none;\" alt=\"\" />",
    /* 13 */                "<a href=\"\\1\">\\2</a>",

    /* 14 */                "<blockquote><p><strong>\\1:</strong><br />\\2</p></blockquote>",
    /* 15 */                "<blockquote><p>\\1</p></blockquote>",

    /* 16 */                "<ul>",
    /* 17 */                "</ul>",
    /* 18 */                "<li>",
                            
    "\n",
                            );

            
    $smilies_arr explode(","$config_smilies);
            foreach(
    $smilies_arr as $smile){
                
    $smile trim($smile);
                
    $find[] = "':$smile:'";
                
    $replace[] = "<img style=\"border: none;\" alt=\"$smile\" src=\"$config_http_script_dir/data/emoticons/$smile.gif\" />";
            }
        }
        elseif(
    $way == "add"){

            
    $find = array(
                        
    "'\|'",
                        
    "'\r'",
                         );
            
    $replace = array(
                        
    "|",
                        
    "",
                         );
    /* // Replaced by Format Switcher plugin
            if($use_html != TRUE){
                $find[]     = "'<'";
                $find[]     = "'>'";

                $replace[]     = "&lt;";
                $replace[]     = "&gt;";
            }
            if($replce_n_to_br == TRUE){
                $find[]     = "'\n'";
                $replace[]     = "<br />";
            }else{ */
                
    $find[]     = "'\n'";
                
    $replace[]     = "{nl}";
            
    // }

        
    }
        elseif(
    $way == "admin"){

            
    $find = array(
                        
    "''",
                        
    "'<br />'",
                        
    "'{nl}'",
                        );
            
    $replace = array(
                        
    "",
                        
    "\n",
                        
    "\n",
                         );

        }

    $sourse  preg_replace($find,$replace,$sourse);
    return 
    $sourse;
    }

    ?>

  5. #5
    Free Geek computerages's Avatar
    Join Date
    Oct 2004
    Location
    /dev/null
    Posts
    1,071
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Anders N
    computerages:
    This is the file:
    try this out:
    PHP Code:
    <?PHP

    if(!$PHP_SELF){
        if(
    $HTTP_POST_VARS)     {extract($HTTP_POST_VARSEXTR_PREFIX_SAME"post_");}
        if(
    $HTTP_GET_VARS)      {extract($HTTP_GET_VARSEXTR_PREFIX_SAME"get_");}
        if(
    $HTTP_COOKIE_VARS)    {extract($HTTP_COOKIE_VARSEXTR_PREFIX_SAME"cookie_");}
        if(
    $HTTP_ENV_VARS)         {extract($HTTP_ENV_VARSEXTR_PREFIX_SAME"env_");}
    }
    if(
    $PHP_SELF == ""){ $PHP_SELF $HTTP_SERVER_VARS["PHP_SELF"]; }

    ///////////////////////////////////////////////////////
    // Function:     formatsize
    // Description: Format the size of given file
    /*
    function formatsize($file_size){
        if($file_size >= 1073741824)
            {$file_size = round($file_size / 1073741824 * 100) / 100 . "GB";}
        elseif($file_size >= 1048576)
            {$file_size = round($file_size / 1048576 * 100) / 100 . "MB";}
        elseif($file_size >= 1024)
            {$file_size = round($file_size / 1024 * 100) / 100 . "KB";}
        else{$file_size = $file_size . "b";}
    return $file_size;
    }
    */
    ///////////////////////////////////////////////////////
    // Class:     microTimer
    // Description: calculates the micro time

    class microTimer {
        function 
    start() {
            global 
    $starttime;
            
    $mtime microtime ();
            
    $mtime explode (' '$mtime);
            
    $mtime $mtime[1] + $mtime[0];
            
    $starttime $mtime;
        }
        function 
    stop() {
            global 
    $starttime;
            
    $mtime microtime ();
            
    $mtime explode (' '$mtime);
            
    $mtime $mtime[1] + $mtime[0];
            
    $endtime $mtime;
            
    $totaltime round (($endtime $starttime), 5);
            return 
    $totaltime;
        }
    }

    ///////////////////////////////////////////////////////
    // Function:     check_login
    // Description: Check login information

    function check_login($username$md5_password){
        
    $result FALSE;
        
    $full_member_db file("./data/users.db.php");
        global 
    $member_db;

        foreach(
    $full_member_db as $member_db_line)
        {
            if(!
    eregi("<\?",$member_db_line)){
                
    $member_db explode("|",$member_db_line);
                if(
    strtolower($member_db[2]) == strtolower($username) && $member_db[3] == md5($md5_password))
                {
                    
    $result TRUE;
                    break;
                }
            }
        }
        return 
    $result;
    }

    ///////////////////////////////////////////////////////
    // Function:     cute_query_string
    // Description: Format the Query_String for CuteNews purpuses index.php?

    function cute_query_string($q_string$strips$type="get"){
        foreach(
    $strips as $key){
            
    $strips[$key] = TRUE;
        }
        
    $var_value explode("&"$q_string);

        foreach(
    $var_value as $var_peace){
            
    $parts explode("="$var_peace);
            if(
    $strips[$parts[0]] != TRUE and $parts[0] != ""){
                if(
    $type == "post"){
                    
    $my_q .= "<input type=\"hidden\" name=\"".$parts[0]."\" value=\"".$parts[1]."\" />\n";
                }else{
                    
    $my_q .= "$var_peace&amp;";
                }
            }
        }

    if( 
    substr($my_q, -5) == "&amp;" ){ $my_q substr($my_q0, -5); }

    return 
    $my_q;
    }

    ///////////////////////////////////////////////////////
    // Function:    Flooder
    // Description: Flood Protection Function
    function flooder($ip$comid){
        global 
    $cutepath$config_flood_time;

        
    $old_db file("$cutepath/data/flood.db.php");
        
    $new_db fopen("$cutepath/data/flood.db.php"w);
        
    $result FALSE;
        foreach(
    $old_db as $old_db_line){
            
    $old_db_arr explode("|"$old_db_line);

            if((
    $old_db_arr[0] + $config_flood_time) > time() ){
                
    fwrite($new_db$old_db_line);
                if(
    $old_db_arr[1] == $ip and $old_db_arr[2] == $comid)
                { 
    $result TRUE; }
            }
        }
        
    fclose($new_db);
        return 
    $result;
    }

    ////////////////////////////////////////////////////////
    // Function:     msg
    // Description: Displays message to user

    function msg($type$title$text$back=FALSE){
      
    echoheader($type$title);
      global 
    $lang;
          echo
    "$text";
        if(
    $back){
            echo
    "<br /><br /> <a href=\"$back\">go back</a>";
        }
      
    echofooter();
    exit();
    }

    ////////////////////////////////////////////////////////
    // Function:     echoheader
    // Description: Displays header skin

    function echoheader($image$header_text){
        global 
    $PHP_SELF$is_loged_in$config_skin$skin_header$lang_content_type$skin_menu$skin_prefix$config_version_name$config_version_id;

        if(
    $is_loged_in == TRUE){ $skin_header preg_replace("/{menu}/""$skin_menu""$skin_header"); }
        else { 
    $skin_header preg_replace("/{menu}/"" &nbsp; $config_version_name""$skin_header"); }
        
    $skin_header preg_replace("/{image-name}/""${skin_prefix}${image}"$skin_header);
        
    $skin_header preg_replace("/{header-text}/"$header_text$skin_header);
        
    $skin_header preg_replace("/{content-type}/"$lang_content_type$skin_header);
        
    $skin_header preg_replace("/{copyrights}/""Powered by <a href=\"http://appelsinjuice.org/?vis=cutenews-aj\">$config_version_name v.$config_version_id</a>  2004  ( forked from <a href=\"http://cutephp.com/\">Cutenews</a> by CutePHP )"$skin_header);

        echo 
    $skin_header;
    }

    ////////////////////////////////////////////////////////
    // Function:     echofooter
    // Description: Displays footer skin

    function echofooter(){

        global 
    $PHP_SELF$is_loged_in$config_skin$skin_footer$lang_content_type$skin_menu$skin_prefix$config_version_name$config_version_id;

        if(
    $is_loged_in == TRUE){ $skin_footer preg_replace("/{menu}/""$skin_menu""$skin_footer"); }
        else { 
    $skin_footer preg_replace("/{menu}/"" &nbsp; $config_version_name""$skin_footer"); }

        
    $skin_footer preg_replace("/{image-name}/""${skin_prefix}${image}"$skin_footer);
        
    $skin_footer preg_replace("/{header-text}/"$header_text$skin_footer);
        
    $skin_footer preg_replace("/{content-type}/"$lang_content_type$skin_footer);
        
    $skin_footer preg_replace("/{copyrights}/""Powered by <a href=\"http://appelsinjuice.org/?vis=cutenews-aj\">$config_version_name v.$config_version_id</a>  2004  ( forked from <a href=\"http://cutephp.com/\">Cutenews</a> by CutePHP )"$skin_footer);

        echo 
    $skin_footer;

    }

    ////////////////////////////////////////////////////////
    // Function:     CountComments
    // Description: Count how many comments belong to a specific article

    function CountComments($id$archive FALSE){

        global 
    $cutepath;

        if(
    $cutepath == ""){ $cutepath "."; }
        
    $result "0";
        if(
    $archive){ $all_comments file("$cutepath/data/archives/${archive}.comments.arch"); }
        else{ 
    $all_comments file("$cutepath/data/comments.txt"); }

        foreach(
    $all_comments as $comment_line)
        {
            
    $comment_arr_1 explode("|>|"$comment_line);
            if(
    $comment_arr_1[0] == $id)
            {
                
    $comment_arr_2 explode("||"$comment_arr_1[1]);
                
    $result count($comment_arr_2)-1;

            }
        }

    return 
    $result;
    }

    ////////////////////////////////////////////////////////
    // Function:     insertSmilies
    // Description: insert smilies for adding into news/comments

    function insertSmilies($insert_location$break_location FALSE)
    {
        global 
    $config_http_script_dir$config_smilies;

        
    $smilies explode(","$config_smilies);
        foreach(
    $smilies as $smile)
        {
            
    $i++; $smile trim($smile);

            
    $output .= "<a href=\"javascript:insertext(':$smile:','$insert_location')\"><img style=\"border: 0px;\" alt=\"$smile\" src=\"$config_http_script_dir/data/emoticons/$smile.gif\" /></a>";
            
    $output .= "&nbsp;";
        }
        return 
    $output;
    }

    ////////////////////////////////////////////////////////
    // Function:     replace_comments
    // Description: Replaces comments charactars
    function replace_comment($way$sourse){
        global 
    $config_http_script_dir$config_smilies;

        
    $sourse stripslashes(trim($sourse));

        if(
    $way == "add"){

            
    $find = array(
                        
    #"'\"'",
                        #"'\''",
                        #"'<'", // replaced by KSES plugin
                        #"'>'", // replaced by KSES plugin
                        
    "'\|'",
                        
    "'\n'",
                        
    "'\r'",
                         );
            
    $replace = array(
                        
    #"&quot;",
                        #"'",
                        #"&lt;", // replaced by KSES plugin
                        #"&gt;", // replaced by KSES plugin
                        
    "|",
                        
    "<br />",
                        
    "",
                         );

        }
        elseif(
    $way == "show"){

            
    /* $find = array(
                        "'\[b\](.*?)\[/b\]'i",
                        "'\[i\](.*?)\[/i\]'i",
                        "'\[u\](.*?)\[/u\]'i",
                        "'\[del\](.*?)\[/del\]'i",
                        "'\[link\](.*?)\[/link\]'i",
                        "'\[link=(.*?)\](.*?)\[/link\]'i",
                        "'\[url\](.*?)\[/url\]'i",
                        "'\[url=(.*?)\](.*?)\[/url\]'i",
                        "'\[quote\](.*?)\[/quote\]'",
                         );
            $replace = array(
                        "<strong>\\1</strong>",
                        "<em>\\1</em>",
                        "<span style=\"text-decoration: underline;\">\\1</span>",
                        "<del>\\1</del>",
                        "<a href=\"\\1\">\\1</a>",
                        "<a href=\"\\1\">\\2</a>",
                        "<a href=\"\\1\">\\1</a>",
                        "<a href=\"\\1\">\\2</a>",
                        "<blockquote class=\"cutenews\"><p>\\1</p></blockquote>",
                         );
                         */

            
    $smilies_arr explode(","$config_smilies);
            foreach(
    $smilies_arr as $smile){
                
    $smile trim($smile);
                
    $find[] = "':$smile:'";
                
    $replace[] = "<img style=\"border: 0px;\" alt=\"$smile\" src=\"$config_http_script_dir/data/emoticons/$smile.gif\" />";
            }

        }

    $sourse  preg_replace($find,$replace,$sourse);
    return 
    $sourse;
    }



    ////////////////////////////////////////////////////////
    // Function:     replace_news
    // Description: Replaces news charactars

    function replace_news($way$sourse$replce_n_to_br=TRUE$use_html=TRUE){
        global 
    $config_allow_html_in_news$config_allow_html_in_comments$config_http_script_dir$config_smilies;
        
    $sourse stripslashes($sourse);

        if(
    $way == "show")
        {
            
    $find= array(

    /* 1 */                  "'\[upimage=([^\]]*?) ([^\]]*?)\]'i",
    /* 2 */                    "'\[upimage=(.*?)\]'i",
    /* 3 */                    "'\[b\](.*?)\[/b\]'i",
    /* 4 */                    "'\[i\](.*?)\[/i\]'i",
    /* 5 */                    "'\[u\](.*?)\[/u\]'i",
    /* 6 */                    "'\[link\](.*?)\[/link\]'i",
    /* 7 */                    "'\[color=(.*?)\](.*?)\[/color\]'i",
    /* 8 */                    "'\[size=(.*?)\](.*?)\[/size\]'i",
    /* 9 */                    "'\[font=(.*?)\](.*?)\[/font\]'i",
    /* 10 */                 "'\[align=(.*?)\](.*?)\[/align\]'i",
    /* 12 */                 "'\[image=(.*?)\]'i",
    /* 13 */                 "'\[link=(.*?)\](.*?)\[/link\]'i",

    /* 14 */                "'\[quote=(.*?)\](.*?)\[/quote\]'i",
    /* 15 */                "'\[quote\](.*?)\[/quote\]'i",

    /* 16 */                "'\[list\]'i",
    /* 17 */                "'\[/list\]'i",
    /* 18 */                "'\[\*\]'i",
                            
    "'{nl}'",
                           );

            
    $replace=array(

    /* 1 */                    "<img \\2 src=\"${config_http_script_dir}/skins/images/upskins/images/\\1\" style=\"border: none;\" alt=\"\" />",
    /* 2 */                    "<img src=\"${config_http_script_dir}/skins/images/upskins/images/\\1\" style=\"border: none;\" alt=\"\" />",
    /* 3 */                    "<strong>\\1</strong>",
    /* 4 */                    "<em>\\1</em>",
    /* 5 */                    "<span style=\"text-decoration: underline;\">\\1</span>",
    /* 6 */                    "<a href=\"\\1\">\\1</a>",
    /* 7 */                    "<span style=\"color: \\1;\">\\2</span>",
    /* 8 */                    "<span style=\"font-size: \\1pt;\">\\2</span>",
    /* 9 */                    "<span style=\"font-family: \\1;\">\\2</span>",
    /* 10 */                "<div style=\"text-align: \\1;\">\\2</div>",
    /* 12 */                "<img src=\"\\1\" style=\"border: none;\" alt=\"\" />",
    /* 13 */                "<a href=\"\\1\">\\2</a>",

    /* 14 */                "<blockquote><p><strong>\\1:</strong><br />\\2</p></blockquote>",
    /* 15 */                "<blockquote><p>\\1</p></blockquote>",

    /* 16 */                "<ul>",
    /* 17 */                "</ul>",
    /* 18 */                "<li>",
                            
    "\n",
                            );

            
    $smilies_arr explode(","$config_smilies);
            foreach(
    $smilies_arr as $smile){
                
    $smile trim($smile);
                
    $find[] = "':$smile:'";
                
    $replace[] = "<img style=\"border: none;\" alt=\"$smile\" src=\"$config_http_script_dir/data/emoticons/$smile.gif\" />";
            }
        }
        elseif(
    $way == "add"){

            
    $find = array(
                        
    "'\|'",
                        
    "'\r'",
                         );
            
    $replace = array(
                        
    "|",
                        
    "",
                         );
    /* // Replaced by Format Switcher plugin
            if($use_html != TRUE){
                $find[]     = "'<'";
                $find[]     = "'>'";

                $replace[]     = "&lt;";
                $replace[]     = "&gt;";
            }
            if($replce_n_to_br == TRUE){
                $find[]     = "'\n'";
                $replace[]     = "<br />";
            }else{ */
                
    $find[]     = "'\n'";
                
    $replace[]     = "{nl}";
            
    // }

        
    }
        elseif(
    $way == "admin"){

            
    $find = array(
                        
    "''",
                        
    "'<br />'",
                        
    "'{nl}'",
                        );
            
    $replace = array(
                        
    "",
                        
    "\n",
                        
    "\n",
                         );

        }

    $sourse  preg_replace($find,$replace,$sourse);
    return 
    $sourse;
    }

    ?>

  6. #6
    SitePoint Enthusiast Anders N's Avatar
    Join Date
    Dec 2004
    Location
    Norway
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    New error: :P

    Fatal error: Cannot redeclare class microtimer in /usr/home/web/wno32422/ringetoner/inc/functions.inc.php on line 30

  7. #7
    Free Geek computerages's Avatar
    Join Date
    Oct 2004
    Location
    /dev/null
    Posts
    1,071
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Anders N
    New error: :P

    Fatal error: Cannot redeclare class microtimer in /usr/home/web/wno32422/ringetoner/inc/functions.inc.php on line 30
    PHP Code:
    <?PHP

    if(!$PHP_SELF){
        if(
    $HTTP_POST_VARS)     {extract($HTTP_POST_VARSEXTR_PREFIX_SAME"post_");}
        if(
    $HTTP_GET_VARS)      {extract($HTTP_GET_VARSEXTR_PREFIX_SAME"get_");}
        if(
    $HTTP_COOKIE_VARS)    {extract($HTTP_COOKIE_VARSEXTR_PREFIX_SAME"cookie_");}
        if(
    $HTTP_ENV_VARS)         {extract($HTTP_ENV_VARSEXTR_PREFIX_SAME"env_");}
    }
    if(
    $PHP_SELF == ""){ $PHP_SELF $HTTP_SERVER_VARS["PHP_SELF"]; }

    ///////////////////////////////////////////////////////
    // Function:     formatsize
    // Description: Format the size of given file
    /*
    function formatsize($file_size){
        if($file_size >= 1073741824)
            {$file_size = round($file_size / 1073741824 * 100) / 100 . "GB";}
        elseif($file_size >= 1048576)
            {$file_size = round($file_size / 1048576 * 100) / 100 . "MB";}
        elseif($file_size >= 1024)
            {$file_size = round($file_size / 1024 * 100) / 100 . "KB";}
        else{$file_size = $file_size . "b";}
    return $file_size;
    }
    */
    ///////////////////////////////////////////////////////
    // Class:     microTimer
    // Description: calculates the micro time
    /*
    class microTimer {
        function start() {
            global $starttime;
            $mtime = microtime ();
            $mtime = explode (' ', $mtime);
            $mtime = $mtime[1] + $mtime[0];
            $starttime = $mtime;
        }
        function stop() {
            global $starttime;
            $mtime = microtime ();
            $mtime = explode (' ', $mtime);
            $mtime = $mtime[1] + $mtime[0];
            $endtime = $mtime;
            $totaltime = round (($endtime - $starttime), 5);
            return $totaltime;
        }
    }
    */
    ///////////////////////////////////////////////////////
    // Function:     check_login
    // Description: Check login information

    function check_login($username$md5_password){
        
    $result FALSE;
        
    $full_member_db file("./data/users.db.php");
        global 
    $member_db;

        foreach(
    $full_member_db as $member_db_line)
        {
            if(!
    eregi("<\?",$member_db_line)){
                
    $member_db explode("|",$member_db_line);
                if(
    strtolower($member_db[2]) == strtolower($username) && $member_db[3] == md5($md5_password))
                {
                    
    $result TRUE;
                    break;
                }
            }
        }
        return 
    $result;
    }

    ///////////////////////////////////////////////////////
    // Function:     cute_query_string
    // Description: Format the Query_String for CuteNews purpuses index.php?

    function cute_query_string($q_string$strips$type="get"){
        foreach(
    $strips as $key){
            
    $strips[$key] = TRUE;
        }
        
    $var_value explode("&"$q_string);

        foreach(
    $var_value as $var_peace){
            
    $parts explode("="$var_peace);
            if(
    $strips[$parts[0]] != TRUE and $parts[0] != ""){
                if(
    $type == "post"){
                    
    $my_q .= "<input type=\"hidden\" name=\"".$parts[0]."\" value=\"".$parts[1]."\" />\n";
                }else{
                    
    $my_q .= "$var_peace&amp;";
                }
            }
        }

    if( 
    substr($my_q, -5) == "&amp;" ){ $my_q substr($my_q0, -5); }

    return 
    $my_q;
    }

    ///////////////////////////////////////////////////////
    // Function:    Flooder
    // Description: Flood Protection Function
    function flooder($ip$comid){
        global 
    $cutepath$config_flood_time;

        
    $old_db file("$cutepath/data/flood.db.php");
        
    $new_db fopen("$cutepath/data/flood.db.php"w);
        
    $result FALSE;
        foreach(
    $old_db as $old_db_line){
            
    $old_db_arr explode("|"$old_db_line);

            if((
    $old_db_arr[0] + $config_flood_time) > time() ){
                
    fwrite($new_db$old_db_line);
                if(
    $old_db_arr[1] == $ip and $old_db_arr[2] == $comid)
                { 
    $result TRUE; }
            }
        }
        
    fclose($new_db);
        return 
    $result;
    }

    ////////////////////////////////////////////////////////
    // Function:     msg
    // Description: Displays message to user

    function msg($type$title$text$back=FALSE){
      
    echoheader($type$title);
      global 
    $lang;
          echo
    "$text";
        if(
    $back){
            echo
    "<br /><br /> <a href=\"$back\">go back</a>";
        }
      
    echofooter();
    exit();
    }

    ////////////////////////////////////////////////////////
    // Function:     echoheader
    // Description: Displays header skin

    function echoheader($image$header_text){
        global 
    $PHP_SELF$is_loged_in$config_skin$skin_header$lang_content_type$skin_menu$skin_prefix$config_version_name$config_version_id;

        if(
    $is_loged_in == TRUE){ $skin_header preg_replace("/{menu}/""$skin_menu""$skin_header"); }
        else { 
    $skin_header preg_replace("/{menu}/"" &nbsp; $config_version_name""$skin_header"); }
        
    $skin_header preg_replace("/{image-name}/""${skin_prefix}${image}"$skin_header);
        
    $skin_header preg_replace("/{header-text}/"$header_text$skin_header);
        
    $skin_header preg_replace("/{content-type}/"$lang_content_type$skin_header);
        
    $skin_header preg_replace("/{copyrights}/""Powered by <a href=\"http://appelsinjuice.org/?vis=cutenews-aj\">$config_version_name v.$config_version_id</a>  2004  ( forked from <a href=\"http://cutephp.com/\">Cutenews</a> by CutePHP )"$skin_header);

        echo 
    $skin_header;
    }

    ////////////////////////////////////////////////////////
    // Function:     echofooter
    // Description: Displays footer skin

    function echofooter(){

        global 
    $PHP_SELF$is_loged_in$config_skin$skin_footer$lang_content_type$skin_menu$skin_prefix$config_version_name$config_version_id;

        if(
    $is_loged_in == TRUE){ $skin_footer preg_replace("/{menu}/""$skin_menu""$skin_footer"); }
        else { 
    $skin_footer preg_replace("/{menu}/"" &nbsp; $config_version_name""$skin_footer"); }

        
    $skin_footer preg_replace("/{image-name}/""${skin_prefix}${image}"$skin_footer);
        
    $skin_footer preg_replace("/{header-text}/"$header_text$skin_footer);
        
    $skin_footer preg_replace("/{content-type}/"$lang_content_type$skin_footer);
        
    $skin_footer preg_replace("/{copyrights}/""Powered by <a href=\"http://appelsinjuice.org/?vis=cutenews-aj\">$config_version_name v.$config_version_id</a>  2004  ( forked from <a href=\"http://cutephp.com/\">Cutenews</a> by CutePHP )"$skin_footer);

        echo 
    $skin_footer;

    }

    ////////////////////////////////////////////////////////
    // Function:     CountComments
    // Description: Count how many comments belong to a specific article

    function CountComments($id$archive FALSE){

        global 
    $cutepath;

        if(
    $cutepath == ""){ $cutepath "."; }
        
    $result "0";
        if(
    $archive){ $all_comments file("$cutepath/data/archives/${archive}.comments.arch"); }
        else{ 
    $all_comments file("$cutepath/data/comments.txt"); }

        foreach(
    $all_comments as $comment_line)
        {
            
    $comment_arr_1 explode("|>|"$comment_line);
            if(
    $comment_arr_1[0] == $id)
            {
                
    $comment_arr_2 explode("||"$comment_arr_1[1]);
                
    $result count($comment_arr_2)-1;

            }
        }

    return 
    $result;
    }

    ////////////////////////////////////////////////////////
    // Function:     insertSmilies
    // Description: insert smilies for adding into news/comments

    function insertSmilies($insert_location$break_location FALSE)
    {
        global 
    $config_http_script_dir$config_smilies;

        
    $smilies explode(","$config_smilies);
        foreach(
    $smilies as $smile)
        {
            
    $i++; $smile trim($smile);

            
    $output .= "<a href=\"javascript:insertext(':$smile:','$insert_location')\"><img style=\"border: 0px;\" alt=\"$smile\" src=\"$config_http_script_dir/data/emoticons/$smile.gif\" /></a>";
            
    $output .= "&nbsp;";
        }
        return 
    $output;
    }

    ////////////////////////////////////////////////////////
    // Function:     replace_comments
    // Description: Replaces comments charactars
    function replace_comment($way$sourse){
        global 
    $config_http_script_dir$config_smilies;

        
    $sourse stripslashes(trim($sourse));

        if(
    $way == "add"){

            
    $find = array(
                        
    #"'\"'",
                        #"'\''",
                        #"'<'", // replaced by KSES plugin
                        #"'>'", // replaced by KSES plugin
                        
    "'\|'",
                        
    "'\n'",
                        
    "'\r'",
                         );
            
    $replace = array(
                        
    #"&quot;",
                        #"'",
                        #"&lt;", // replaced by KSES plugin
                        #"&gt;", // replaced by KSES plugin
                        
    "|",
                        
    "<br />",
                        
    "",
                         );

        }
        elseif(
    $way == "show"){

            
    /* $find = array(
                        "'\[b\](.*?)\[/b\]'i",
                        "'\[i\](.*?)\[/i\]'i",
                        "'\[u\](.*?)\[/u\]'i",
                        "'\[del\](.*?)\[/del\]'i",
                        "'\[link\](.*?)\[/link\]'i",
                        "'\[link=(.*?)\](.*?)\[/link\]'i",
                        "'\[url\](.*?)\[/url\]'i",
                        "'\[url=(.*?)\](.*?)\[/url\]'i",
                        "'\[quote\](.*?)\[/quote\]'",
                         );
            $replace = array(
                        "<strong>\\1</strong>",
                        "<em>\\1</em>",
                        "<span style=\"text-decoration: underline;\">\\1</span>",
                        "<del>\\1</del>",
                        "<a href=\"\\1\">\\1</a>",
                        "<a href=\"\\1\">\\2</a>",
                        "<a href=\"\\1\">\\1</a>",
                        "<a href=\"\\1\">\\2</a>",
                        "<blockquote class=\"cutenews\"><p>\\1</p></blockquote>",
                         );
                         */

            
    $smilies_arr explode(","$config_smilies);
            foreach(
    $smilies_arr as $smile){
                
    $smile trim($smile);
                
    $find[] = "':$smile:'";
                
    $replace[] = "<img style=\"border: 0px;\" alt=\"$smile\" src=\"$config_http_script_dir/data/emoticons/$smile.gif\" />";
            }

        }

    $sourse  preg_replace($find,$replace,$sourse);
    return 
    $sourse;
    }



    ////////////////////////////////////////////////////////
    // Function:     replace_news
    // Description: Replaces news charactars

    function replace_news($way$sourse$replce_n_to_br=TRUE$use_html=TRUE){
        global 
    $config_allow_html_in_news$config_allow_html_in_comments$config_http_script_dir$config_smilies;
        
    $sourse stripslashes($sourse);

        if(
    $way == "show")
        {
            
    $find= array(

    /* 1 */                  "'\[upimage=([^\]]*?) ([^\]]*?)\]'i",
    /* 2 */                    "'\[upimage=(.*?)\]'i",
    /* 3 */                    "'\[b\](.*?)\[/b\]'i",
    /* 4 */                    "'\[i\](.*?)\[/i\]'i",
    /* 5 */                    "'\[u\](.*?)\[/u\]'i",
    /* 6 */                    "'\[link\](.*?)\[/link\]'i",
    /* 7 */                    "'\[color=(.*?)\](.*?)\[/color\]'i",
    /* 8 */                    "'\[size=(.*?)\](.*?)\[/size\]'i",
    /* 9 */                    "'\[font=(.*?)\](.*?)\[/font\]'i",
    /* 10 */                 "'\[align=(.*?)\](.*?)\[/align\]'i",
    /* 12 */                 "'\[image=(.*?)\]'i",
    /* 13 */                 "'\[link=(.*?)\](.*?)\[/link\]'i",

    /* 14 */                "'\[quote=(.*?)\](.*?)\[/quote\]'i",
    /* 15 */                "'\[quote\](.*?)\[/quote\]'i",

    /* 16 */                "'\[list\]'i",
    /* 17 */                "'\[/list\]'i",
    /* 18 */                "'\[\*\]'i",
                            
    "'{nl}'",
                           );

            
    $replace=array(

    /* 1 */                    "<img \\2 src=\"${config_http_script_dir}/skins/images/upskins/images/\\1\" style=\"border: none;\" alt=\"\" />",
    /* 2 */                    "<img src=\"${config_http_script_dir}/skins/images/upskins/images/\\1\" style=\"border: none;\" alt=\"\" />",
    /* 3 */                    "<strong>\\1</strong>",
    /* 4 */                    "<em>\\1</em>",
    /* 5 */                    "<span style=\"text-decoration: underline;\">\\1</span>",
    /* 6 */                    "<a href=\"\\1\">\\1</a>",
    /* 7 */                    "<span style=\"color: \\1;\">\\2</span>",
    /* 8 */                    "<span style=\"font-size: \\1pt;\">\\2</span>",
    /* 9 */                    "<span style=\"font-family: \\1;\">\\2</span>",
    /* 10 */                "<div style=\"text-align: \\1;\">\\2</div>",
    /* 12 */                "<img src=\"\\1\" style=\"border: none;\" alt=\"\" />",
    /* 13 */                "<a href=\"\\1\">\\2</a>",

    /* 14 */                "<blockquote><p><strong>\\1:</strong><br />\\2</p></blockquote>",
    /* 15 */                "<blockquote><p>\\1</p></blockquote>",

    /* 16 */                "<ul>",
    /* 17 */                "</ul>",
    /* 18 */                "<li>",
                            
    "\n",
                            );

            
    $smilies_arr explode(","$config_smilies);
            foreach(
    $smilies_arr as $smile){
                
    $smile trim($smile);
                
    $find[] = "':$smile:'";
                
    $replace[] = "<img style=\"border: none;\" alt=\"$smile\" src=\"$config_http_script_dir/data/emoticons/$smile.gif\" />";
            }
        }
        elseif(
    $way == "add"){

            
    $find = array(
                        
    "'\|'",
                        
    "'\r'",
                         );
            
    $replace = array(
                        
    "|",
                        
    "",
                         );
    /* // Replaced by Format Switcher plugin
            if($use_html != TRUE){
                $find[]     = "'<'";
                $find[]     = "'>'";

                $replace[]     = "&lt;";
                $replace[]     = "&gt;";
            }
            if($replce_n_to_br == TRUE){
                $find[]     = "'\n'";
                $replace[]     = "<br />";
            }else{ */
                
    $find[]     = "'\n'";
                
    $replace[]     = "{nl}";
            
    // }

        
    }
        elseif(
    $way == "admin"){

            
    $find = array(
                        
    "''",
                        
    "'<br />'",
                        
    "'{nl}'",
                        );
            
    $replace = array(
                        
    "",
                        
    "\n",
                        
    "\n",
                         );

        }

    $sourse  preg_replace($find,$replace,$sourse);
    return 
    $sourse;
    }

    ?>

  8. #8
    SitePoint Enthusiast Anders N's Avatar
    Join Date
    Dec 2004
    Location
    Norway
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is it ok to just keep on posting these?

    Fatal error: Cannot redeclare check_login() (previously declared in /usr/home/web/wno32422/bakgrunner/inc/functions.inc.php:53) in /usr/home/web/wno32422/ringetoner/inc/functions.inc.php on line 53

  9. #9
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try
    <?PHP
    $number = 4;
    $template = 'siste';
    $PHP_SELF = 'bakgrunneropen.php';
    include_once("bakgrunner/show_news.php");
    ?>

    for both of them and see if it solves the problem
    good luck

  10. #10
    SitePoint Enthusiast Anders N's Avatar
    Join Date
    Dec 2004
    Location
    Norway
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I did, and it don't...

  11. #11
    Free Geek computerages's Avatar
    Join Date
    Oct 2004
    Location
    /dev/null
    Posts
    1,071
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try this one out, it should work like a charm.. and it is ok to keep on posting until you get it right..

    PHP Code:
    <?PHP

    if(!$PHP_SELF){
        if(
    $HTTP_POST_VARS)     {extract($HTTP_POST_VARSEXTR_PREFIX_SAME"post_");}
        if(
    $HTTP_GET_VARS)      {extract($HTTP_GET_VARSEXTR_PREFIX_SAME"get_");}
        if(
    $HTTP_COOKIE_VARS)    {extract($HTTP_COOKIE_VARSEXTR_PREFIX_SAME"cookie_");}
        if(
    $HTTP_ENV_VARS)         {extract($HTTP_ENV_VARSEXTR_PREFIX_SAME"env_");}
    }
    if(
    $PHP_SELF == ""){ $PHP_SELF $HTTP_SERVER_VARS["PHP_SELF"]; }

    ///////////////////////////////////////////////////////
    // Function:     formatsize
    // Description: Format the size of given file
    /*
    function formatsize($file_size){
        if($file_size >= 1073741824)
            {$file_size = round($file_size / 1073741824 * 100) / 100 . "GB";}
        elseif($file_size >= 1048576)
            {$file_size = round($file_size / 1048576 * 100) / 100 . "MB";}
        elseif($file_size >= 1024)
            {$file_size = round($file_size / 1024 * 100) / 100 . "KB";}
        else{$file_size = $file_size . "b";}
    return $file_size;
    }
    */
    ///////////////////////////////////////////////////////
    // Class:     microTimer
    // Description: calculates the micro time
    /*
    class microTimer {
        function start() {
            global $starttime;
            $mtime = microtime ();
            $mtime = explode (' ', $mtime);
            $mtime = $mtime[1] + $mtime[0];
            $starttime = $mtime;
        }
        function stop() {
            global $starttime;
            $mtime = microtime ();
            $mtime = explode (' ', $mtime);
            $mtime = $mtime[1] + $mtime[0];
            $endtime = $mtime;
            $totaltime = round (($endtime - $starttime), 5);
            return $totaltime;
        }
    }
    */
    ///////////////////////////////////////////////////////
    // Function:     check_login
    // Description: Check login information
     /*
    function check_login($username, $md5_password){
        $result = FALSE;
        $full_member_db = file("./data/users.db.php");
        global $member_db;

        foreach($full_member_db as $member_db_line)
        {
            if(!eregi("<\?",$member_db_line)){
                $member_db = explode("|",$member_db_line);
                if(strtolower($member_db[2]) == strtolower($username) && $member_db[3] == md5($md5_password))
                {
                    $result = TRUE;
                    break;
                }
            }
        }
        return $result;
    }
     */
    ///////////////////////////////////////////////////////
    // Function:     cute_query_string
    // Description: Format the Query_String for CuteNews purpuses index.php?
    /*
    function cute_query_string($q_string, $strips, $type="get"){
        foreach($strips as $key){
            $strips[$key] = TRUE;
        }
        $var_value = explode("&", $q_string);

        foreach($var_value as $var_peace){
            $parts = explode("=", $var_peace);
            if($strips[$parts[0]] != TRUE and $parts[0] != ""){
                if($type == "post"){
                    $my_q .= "<input type=\"hidden\" name=\"".$parts[0]."\" value=\"".$parts[1]."\" />\n";
                }else{
                    $my_q .= "$var_peace&amp;";
                }
            }
        }

    if( substr($my_q, -5) == "&amp;" ){ $my_q = substr($my_q, 0, -5); }

    return $my_q;
    }
    */
    ///////////////////////////////////////////////////////
    // Function:    Flooder
    // Description: Flood Protection Function
    /*
    function flooder($ip, $comid){
        global $cutepath, $config_flood_time;

        $old_db = file("$cutepath/data/flood.db.php");
        $new_db = fopen("$cutepath/data/flood.db.php", w);
        $result = FALSE;
        foreach($old_db as $old_db_line){
            $old_db_arr = explode("|", $old_db_line);

            if(($old_db_arr[0] + $config_flood_time) > time() ){
                fwrite($new_db, $old_db_line);
                if($old_db_arr[1] == $ip and $old_db_arr[2] == $comid)
                { $result = TRUE; }
            }
        }
        fclose($new_db);
        return $result;
    }
     */
    ////////////////////////////////////////////////////////
    // Function:     msg
    // Description: Displays message to user
     /*
    function msg($type, $title, $text, $back=FALSE){
      echoheader($type, $title);
      global $lang;
          echo"$text";
        if($back){
            echo"<br /><br /> <a href=\"$back\">go back</a>";
        }
      echofooter();
    exit();
    }
      */
    ////////////////////////////////////////////////////////
    // Function:     echoheader
    // Description: Displays header skin
    /*
    function echoheader($image, $header_text){
        global $PHP_SELF, $is_loged_in, $config_skin, $skin_header, $lang_content_type, $skin_menu, $skin_prefix, $config_version_name, $config_version_id;

        if($is_loged_in == TRUE){ $skin_header = preg_replace("/{menu}/", "$skin_menu", "$skin_header"); }
        else { $skin_header = preg_replace("/{menu}/", " &nbsp; $config_version_name", "$skin_header"); }
        $skin_header = preg_replace("/{image-name}/", "${skin_prefix}${image}", $skin_header);
        $skin_header = preg_replace("/{header-text}/", $header_text, $skin_header);
        $skin_header = preg_replace("/{content-type}/", $lang_content_type, $skin_header);
        $skin_header = preg_replace("/{copyrights}/", "Powered by <a href=\"http://appelsinjuice.org/?vis=cutenews-aj\">$config_version_name v.$config_version_id</a>  2004  ( forked from <a href=\"http://cutephp.com/\">Cutenews</a> by CutePHP )", $skin_header);

        echo $skin_header;
    }
    */
    ////////////////////////////////////////////////////////
    // Function:     echofooter
    // Description: Displays footer skin
    /*
    function echofooter(){

        global $PHP_SELF, $is_loged_in, $config_skin, $skin_footer, $lang_content_type, $skin_menu, $skin_prefix, $config_version_name, $config_version_id;

        if($is_loged_in == TRUE){ $skin_footer = preg_replace("/{menu}/", "$skin_menu", "$skin_footer"); }
        else { $skin_footer = preg_replace("/{menu}/", " &nbsp; $config_version_name", "$skin_footer"); }

        $skin_footer = preg_replace("/{image-name}/", "${skin_prefix}${image}", $skin_footer);
        $skin_footer = preg_replace("/{header-text}/", $header_text, $skin_footer);
        $skin_footer = preg_replace("/{content-type}/", $lang_content_type, $skin_footer);
        $skin_footer = preg_replace("/{copyrights}/", "Powered by <a href=\"http://appelsinjuice.org/?vis=cutenews-aj\">$config_version_name v.$config_version_id</a>  2004  ( forked from <a href=\"http://cutephp.com/\">Cutenews</a> by CutePHP )", $skin_footer);

        echo $skin_footer;

    }
    */
    ////////////////////////////////////////////////////////
    // Function:     CountComments
    // Description: Count how many comments belong to a specific article
    /*
    function CountComments($id, $archive = FALSE){

        global $cutepath;

        if($cutepath == ""){ $cutepath = "."; }
        $result = "0";
        if($archive){ $all_comments = file("$cutepath/data/archives/${archive}.comments.arch"); }
        else{ $all_comments = file("$cutepath/data/comments.txt"); }

        foreach($all_comments as $comment_line)
        {
            $comment_arr_1 = explode("|>|", $comment_line);
            if($comment_arr_1[0] == $id)
            {
                $comment_arr_2 = explode("||", $comment_arr_1[1]);
                $result = count($comment_arr_2)-1;

            }
        }

    return $result;
    }
    */
    ////////////////////////////////////////////////////////
    // Function:     insertSmilies
    // Description: insert smilies for adding into news/comments
    /*
    function insertSmilies($insert_location, $break_location = FALSE)
    {
        global $config_http_script_dir, $config_smilies;

        $smilies = explode(",", $config_smilies);
        foreach($smilies as $smile)
        {
            $i++; $smile = trim($smile);

            $output .= "<a href=\"javascript:insertext(':$smile:','$insert_location')\"><img style=\"border: 0px;\" alt=\"$smile\" src=\"$config_http_script_dir/data/emoticons/$smile.gif\" /></a>";
            $output .= "&nbsp;";
        }
        return $output;
    }
    */
    ////////////////////////////////////////////////////////
    // Function:     replace_comments
    // Description: Replaces comments charactars
    /*
    function replace_comment($way, $sourse){
        global $config_http_script_dir, $config_smilies;

        $sourse = stripslashes(trim($sourse));

        if($way == "add"){

            $find = array(
                        #"'\"'",
                        #"'\''",
                        #"'<'", // replaced by KSES plugin
                        #"'>'", // replaced by KSES plugin
                        "'\|'",
                        "'\n'",
                        "'\r'",
                         );
            $replace = array(
                        #"&quot;",
                        #"'",
                        #"&lt;", // replaced by KSES plugin
                        #"&gt;", // replaced by KSES plugin
                        "|",
                        "<br />",
                        "",
                         );

        }
        elseif($way == "show"){

            /* $find = array(
                        "'\[b\](.*?)\[/b\]'i",
                        "'\[i\](.*?)\[/i\]'i",
                        "'\[u\](.*?)\[/u\]'i",
                        "'\[del\](.*?)\[/del\]'i",
                        "'\[link\](.*?)\[/link\]'i",
                        "'\[link=(.*?)\](.*?)\[/link\]'i",
                        "'\[url\](.*?)\[/url\]'i",
                        "'\[url=(.*?)\](.*?)\[/url\]'i",
                        "'\[quote\](.*?)\[/quote\]'",
                         );
            $replace = array(
                        "<strong>\\1</strong>",
                        "<em>\\1</em>",
                        "<span style=\"text-decoration: underline;\">\\1</span>",
                        "<del>\\1</del>",
                        "<a href=\"\\1\">\\1</a>",
                        "<a href=\"\\1\">\\2</a>",
                        "<a href=\"\\1\">\\1</a>",
                        "<a href=\"\\1\">\\2</a>",
                        "<blockquote class=\"cutenews\"><p>\\1</p></blockquote>",
                         );
                         */
      /*
            $smilies_arr = explode(",", $config_smilies);
            foreach($smilies_arr as $smile){
                $smile = trim($smile);
                $find[] = "':$smile:'";
                $replace[] = "<img style=\"border: 0px;\" alt=\"$smile\" src=\"$config_http_script_dir/data/emoticons/$smile.gif\" />";
            }

        }

    $sourse  = preg_replace($find,$replace,$sourse);
    return $sourse;
    }

     */



    ?>

  12. #12
    SitePoint Enthusiast Anders N's Avatar
    Join Date
    Dec 2004
    Location
    Norway
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, it worked now. Only problem is, now i get this error message on the page that only uses the last installation:

    Fatal error: Call to undefined function: cute_query_string() in /usr/home/web/wno32422/ringetoner/inc/shows.inc.php on line 23

    See it in action on http://mobilmoro.net/ringetoner.php

  13. #13
    Free Geek computerages's Avatar
    Join Date
    Oct 2004
    Location
    /dev/null
    Posts
    1,071
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Anders N
    Thanks, it worked now. Only problem is, now i get this error message on the page that only uses the last installation:

    Fatal error: Call to undefined function: cute_query_string() in /usr/home/web/wno32422/ringetoner/inc/shows.inc.php on line 23

    See it in action on http://mobilmoro.net/ringetoner.php
    Glad to hear that! Could you please post /ringetoner/inc/shows.inc.php here?

  14. #14
    SitePoint Enthusiast Anders N's Avatar
    Join Date
    Dec 2004
    Location
    Norway
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [PHP]
    <?PHP

    if (!defined('PLUGIN_FRAMEWORK_VERSION')) {
    include($cutepath.'/inc/plugins.php');
    LoadActivePlugins();
    }

    do{ // Used if we want to display some error to the user and halt the rest of the script



    // [locales] v[1] - addblock
    setlocale (LC_ALL, $config_locale_active);
    // [locales] v[1] - End addblock

    // AJB Visible language addon
    $vis_lang_file = $cutepath . "/inc/lang/" . $config_cn_lang . ".visible.php";
    if (file_exists($vis_lang_file)) {
    include($vis_lang_file);
    }
    // END AJBVISLANGADD

    $user_query = cute_query_string($QUERY_STRING, array("start_from", "archive", "subaction", "id", "ucat"));
    $user_post_query = cute_query_string($QUERY_STRING, array("start_from", "archive", "subaction", "id", "ucat"), "post");

    // [locales] v[1] - addblock
    //####################################################################################################################
    // Some localized date setup / Not working ATM
    //####################################################################################################################

    if ($config_date_select && $config_date_select != "Other") {
    $config_timestamp_active = $config_date_select;
    }
    // [locales] v[1] - End addblock
    //####################################################################################################################
    // Define Categories
    //####################################################################################################################
    $cat_lines = file("$cutepath/data/category.db.php");
    foreach($cat_lines as $single_line){
    $cat_arr = explode("|", $single_line);
    $cat[$cat_arr[0]] = $cat_arr[1];
    $cat_icon[$cat_arr[0]]=$cat_arr[2];
    }
    //####################################################################################################################
    // Define Users
    //####################################################################################################################
    $all_users = file("$cutepath/data/users.db.php");
    foreach($all_users as $user)
    {
    if(!eregi("<\?",$member_db_line)){
    $user_arr = explode("|",$user);
    if($user_arr[4] != "")
    {
    if($user_arr[7] != 1 and $user_arr[5] != ""){ $my_names[$user_arr[2]] = "<a href=\"mailto:$user_arr[5]\">$user_arr[4]</a>"; }
    else{ $my_names[$user_arr[2]] = "$user_arr[4]"; }
    $name_to_nick[$user_arr[2]] = $user_arr[4];
    }
    else
    {
    if($user_arr[7] != 1 and $user_arr[5] != ""){ $my_names[$user_arr[2]] = "<a href=\"mailto:$user_arr[5]\">$user_arr[2]</a>"; }
    else{ $my_names[$user_arr[2]] = "$user_arr[2]"; }
    $name_to_nick[$user_arr[2]] = $user_arr[2];
    }

    if($user_arr[7] != 1){ $my_mails[$user_arr[2]] = $user_arr[5]; }
    else{ $my_mails[$user_arr[2]] = ""; }
    $my_passwords[$user_arr[2]] = $user_arr[3];
    $my_users[] = $user_arr[2];
    }
    }
    //####################################################################################################################
    // Add Comment
    //####################################################################################################################
    $allow_add_comment = run_filters('news-allow-comment',$allow_add_comment);
    if($allow_add_comment){
    $name = trim($name);

    echo '<script type="text/javascript">

    function setCookie(name, value, expires, path, domain, secure) {
    var curCookie = name + "=" + escape(value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
    document.cookie = curCookie;
    }

    function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
    } else
    begin += 2;
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    end = dc.length;
    return unescape(dc.substring(begin + prefix.length, end));
    }

    function deleteCookie(name, path, domain) {
    if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
    }

    </script>';

    if(isset($HTTP_X_FORWARDED_FOR)){ $ip = $HTTP_X_FORWARDED_FOR; }
    elseif(isset($HTTP_CLIENT_IP)) { $ip = $HTTP_CLIENT_IP; }
    if($ip == "") { $ip = $REMOTE_ADDR; }
    if($ip == "") { $ip = "not detected";}


    // Check Flood Protection
    if($config_flood_time != 0 and $config_flood_time != "" ){
    if(flooder($ip, $id) == TRUE ){
    echo("<div style=\"text-align: center;\">$lang_floodprot</div>");
    $CN_HALT = TRUE;
    break 1;
    }
    }
    // Check if IP is banned

    $blockip = FALSE;
    $old_ips = file("$cutepath/data/ipban.db.php");
    $new_ips = fopen("$cutepath/data/ipban.db.php", "w");
    @flock ($new_ips,2);
    foreach($old_ips as $old_ip_line){
    $ip_arr = explode("|", $old_ip_line);
    // AJ-FORK allow blocking of incomplete IPs
    if(!stristr($ip, $ip_arr[0])){
    // Oldstatement
    // $ip_arr[0] != $ip //
    fwrite($new_ips, $old_ip_line);
    }else{
    $countblocks = $ip_arr[1] = $ip_arr[1] + 1;
    fwrite($new_ips, "$ip_arr[0]|$countblocks||\n"); $blockip = TRUE;
    }
    }
    @flock ($new_ips,3);
    fclose($new_ips);
    if($blockip){
    echo("<div style=\"text-align: center;\">$lang_blocked</div>");
    $CN_HALT = TRUE;
    break 1;
    }

    // Check if name is Protected
    $is_member = FALSE;
    foreach($all_users as $member_db_line)
    {
    if(!eregi("<\?",$member_db_line) and $member_db_line != ""){
    $user_arr = explode("|",$member_db_line);

    //if the name is protected
    if((strtolower($user_arr[2]) == strtolower($name) or strtolower($user_arr[4]) == strtolower($name)) and $user_arr[3] != md5(md5($password)) and $name != "")
    {
    $comments = preg_replace(array("'\"'", "'\''", "''"), array("&quot;", "&#039;", ""), $comments);
    $name = replace_comment("add", preg_replace("/\n/", "",$name));
    $mail = replace_comment("add", preg_replace("/\n/", "",$mail));

    echo"<div style=\"text-align: center;\">$lang_commentregistered<br />
    <form method=\"post\" action=\"\">
    <input type=\"password\" name=\"password\" />
    <input type=\"hidden\" name=\"name\" value=\"$name\" />
    <input type=\"hidden\" name=\"comments\" value=\"$comments\" />
    <input type=\"hidden\" name=\"mail\" value=\"$mail\" />
    <input type=\"hidden\" name=\"ip\" value=\"$ip\" />
    <input type=\"hidden\" name=\"subaction\" value=\"addcomment\" />
    <input type=\"hidden\" name=\"javasubaction\" value=\"$javasubaction\" />
    <input type=\"hidden\" name=\"show\" value=\"$show\" />
    <input type=\"hidden\" name=\"ucat\" value=\"$ucat\" />
    <input type=\"hidden\" name=\"rememberme\" value=\"$rememberme\" />
    $user_post_query
    <input type=\"submit\" value=\"$lang_commentregisteredbutton\"/></form></div>";
    $CN_HALT = TRUE;
    break 2;
    // exit();
    }

    if(strtolower($user_arr[2]) == strtolower($name)) $is_member = TRUE;
    }
    }

    // Check if only members can post comments
    if($config_only_registered_comment == "yes" and !$is_member){
    echo"<div style=\"text-align: center;\">$lang_onlyregistered</div>";
    $CN_HALT = TRUE;
    break 1;
    }

    //* Wrap long words
    if($config_auto_wrap > 1){
    $comments_arr = explode("\n", $comments);
    foreach($comments_arr as $line){
    $wraped_comm .= ereg_replace("([^ \/\/]{".$config_auto_wrap."})","\\1\n", $line) ."\n";
    }
    if(strlen($name) > $config_auto_wrap){ $name = substr($name, 0, $config_auto_wrap)." ..."; }
    $comments = $wraped_comm;
    }
    //*/

    $comments = replace_comment("add", run_filters('news-posted-comment-content',$comments));
    $name = replace_comment("add", preg_replace("/\n/", "",$name));
    $mail = replace_comment("add", preg_replace("/\n/", "",$mail));

    if($name == " " or $name == ""){
    echo("<div style=\"text-align: center;\">$lang_comment_needname</div>");
    $CN_HALT = TRUE;
    break 1;
    }
    if($mail == " " or $mail == ""){ $mail = "none"; }
    else{ $ok = FALSE;
    if(preg_match("/^[\.A-z0-9_\-]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $mail)) $ok = TRUE;
    elseif($config_allow_url_instead_mail == "yes" and preg_match("/((http(s?):\/\/)|(www\.))([\w\.]+)([\/\w+\.-?]+)/", $mail)) $ok = TRUE;
    elseif($config_allow_url_instead_mail != "yes"){
    echo("<div style=\"text-align: center;\">$lang_comment_invalidmail</div>");
    $CN_HALT = TRUE;
    break 1;
    }
    else{
    echo("<div style=\"text-align: center;\">$lang_comment_needvalidmail</div>");
    $CN_HALT = TRUE;
    break 1;
    }
    }

    if($comments == ""){
    echo("<div style=\"text-align: center;\">$lang_comment_notblank</div>");
    $CN_HALT = TRUE;
    break 1;
    }

    $time = time()+($config_date_adjust*60);

    // Add the Comment
    $old_comments = file("$comm_file");
    $new_comments = fopen("$comm_file", "w");
    @flock ($new_comments,2);
    $found = FALSE;
    foreach($old_comments as $old_comments_line)
    {
    $old_comments_arr = explode("|>|", $old_comments_line);
    if($old_comments_arr[0] == $id)
    {
    $old_comments_arr[1] = trim($old_comments_arr[1]);
    fwrite($new_comments, "$old_comments_arr[0]|>|$old_comments_arr[1]$time|$name|$mail|$ip|$comments||\n");
    $found = TRUE;
    }else{
    fwrite($new_comments, $old_comments_line);
    }
    }
    if(!$found){ fwrite($new_comments, "$id|>|$time|$name|$mail|$ip|$comments||\n"); }
    @flock ($new_comments,3);
    fclose($new_comments);

    // Add Flood Protection
    if($config_flood_time != "0" and $config_flood_time != "" ){

    $flood_file = fopen("$cutepath/data/flood.db.php", "a");
    @flock ($flood_file,2);
    fwrite($flood_file, time()."|$ip|$id|\n");
    @flock ($flood_file,3);
    fclose($flood_file);
    }
    // Sort problems with browser refresh posting comments twice + remembermefeature

    if ($rememberme == "yes") {
    echo "
    <script type=\"text/javascript\">
    var now = new Date();
    now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
    setCookie(\"commentname\", \"$name\", now);
    setCookie(\"commentmail\", \"$mail\", now);
    </script>";
    }
    else {
    echo "
    <script type=\"text/javascript\">
    var now = new Date();
    now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
    deleteCookie(\"commentname\");
    deleteCookie(\"commentmail\");
    </script>";
    }


    echo "
    <!-- Javascript redirect -->
    <script type=\"text/javascript\">self.location.href='http://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}?subaction=$javasubaction&id=$id&archive=$archive&start_from=$start_from&ucat=$ucat&$user_query';</script>";
    }
    //####################################################################################################################
    // Show Full Story
    //####################################################################################################################
    if($allow_full_story){
    $all_active_news = file("$news_file");

    foreach($all_active_news as $active_news)
    {
    $news_arr = explode("|", $active_news);

    if($news_arr[0] == $id and (!$catid or $catid == $news_arr[6]))
    {
    run_actions('news-fullstory-page');

    $found = TRUE;
    if($news_arr[4] == "" and (!eregi("\{short-story\}", $template_full)) ){ $news_arr[4] = $news_arr[3]; }

    if($my_names[$news_arr[1]]){ $my_author = $my_names[$news_arr[1]]; }
    else{ $my_author = $news_arr[1]; }
    $output = $template_full;
    $output = run_filters('news-show-generic', $output);
    $output = str_replace("{title}", $news_arr[2], $output);
    $output = str_replace("{date}", date($config_timestamp_active, $news_arr[0]), $output);
    // Add DATE variable to full story template
    $output = str_replace("{date-local}", strftime($config_timestamp_local_active, $news_arr[0]), $output);
    // END Add DATE variable FS
    $output = str_replace("{author}", $my_author, $output);

    // TEIT highlight-HACK
    if($highlight) {
    $news_arr[3] = str_replace($highlight, "<em>$highlight</em>", $news_arr[3]);
    $news_arr[4] = str_replace($highlight, "<em>$highlight</em>", $news_arr[4]);
    }
    // end teit highlight-hack

    $output = str_replace("{short-story}", run_filters('news-entry-content',$news_arr[3]), $output);
    $output = str_replace("{full-story}", run_filters('news-entry-content',$news_arr[4]), $output);
    if($news_arr[5] != ""){$output = str_replace("{avatar}", "<img alt=\"\" src=\"$news_arr[5]\" style=\"border: none;\" />", $output); }
    else{ $output = str_replace("{avatar}", "", $output); }
    $output = str_replace("{avatar-url}", "$news_arr[5]", $output);

    // Music hack by rilmith 3 lines below.
    if ($news_arr[7] != "") {
    $output = str_replace("{music}", $news_arr[7], $output); }
    else { $output = str_replace("{music}", $config_music_empty, $output); }

    $output = str_replace("{comments-num}", countComments($news_arr[0], $archive), $output);
    $output = str_replace("{category}", $cat[$news_arr[6]], $output);
    $output = str_replace("{category-id}", $news_arr[6], $output);
    if($cat_icon[$news_arr[6]] != ""){ $output = str_replace("{category-icon}", "<img style=\"border: none;\" alt=\"".$cat[$news_arr[6]]." icon\" src=\"".$cat_icon[$news_arr[6]]."\" />", $output); }
    else{ $output = str_replace("{category-icon}", "", $output); }

    if($config_comments_popup == "yes"){
    $output = str_replace("[com-link]","<a href=\"#\" onclick=\"window.open('$config_http_script_dir/show_news.php?subaction=showcomments&amp;template=$template&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]', '_News', '$config_comments_popup_string');return false;\">", $output);
    }else{
    $output = str_replace("[com-link]","<a href=\"$PHP_SELF?subaction=showcomments&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]&amp;$user_query\">", $output);
    }
    $output = str_replace("[/com-link]","</a>", $output);
    $output = str_replace("{author-name}", $name_to_nick[$news_arr[1]], $output);

    if($my_mails[$news_arr[1]] != ""){
    $output = str_replace("[mail]","<a href=\"mailto:".$my_mails[$news_arr[1]]."\">", $output);
    $output = str_replace("[/mail]","</a>", $output);
    }else{
    $output = str_replace("[mail]","", $output);
    $output = str_replace("[/mail]","", $output);
    }
    $output = str_replace("{news-id}", $news_arr[0], $output);
    $output = str_replace("{archive-id}", $archive, $output);
    $output = str_replace("{php-self}", $PHP_SELF, $output);
    $output = str_replace("{cute-http-path}", $config_http_script_dir, $output);

    // XFields v2.1 - addblock
    $xfieldsaction = "templatereplace";
    $xfieldsinput = $output;
    $xfieldsid = $news_arr[0];
    include("xfields.mdu");
    $output = $xfieldsoutput;
    // XFields v2.1 - End addblock

    $output = run_filters('news-entry',$output);

    $output = replace_news("show", $output);

    echo $output;
    $allow_comments = run_filters('news-show-comments', $allow_comments);
    }
    }
    if(!$found){
    echo("<div style=\"text-align: center;\">$lang_article_notfound</div>");
    $CN_HALT = TRUE;
    break 1;
    }
    }
    //####################################################################################################################
    // Show Comments
    //####################################################################################################################
    if($allow_comments){
    $all_comments = file("$comm_file");

    foreach($all_comments as $comment_line)
    {

    $comment_line = trim($comment_line);
    $comment_line_arr = explode("|>|", $comment_line);
    if($id == $comment_line_arr[0])
    {
    $individual_comments = explode("||", $comment_line_arr[1]);
    // Comments Pagination
    if($config_reverse_comments == "yes"){
    $individual_comments = array_reverse($individual_comments);
    $cghost = 1;} else {$cghost = 0;}
    $total_comments = count($individual_comments)-1;
    // Comments Pagination

    // {comnum} (a bloody mess that doesn't make sense this early in the morning!)
    $i = 0;
    if ($config_reverse_comments == "yes") {
    $cjnumber = $total_comments;
    if ($cstart) { $cjnumber -= $cstart -2; }
    }
    else { $cjnumber = 1;
    if ($cstart) { $cjnumber += $cstart -1;}
    }

    foreach($individual_comments as $comment)
    {

    // Comments Pagination
    if ($config_comments_pagination == "Yes") {
    $comment_index++;

    !isset($cnum) and $cnum = $config_comments_pagination_number;
    $cstart < 1 and $cstart = 1+$cghost;

    if ($comment_index < $cstart) continue;
    if ($comment_index >= $cstart + $cnum) break;
    }
    // Comments Pagination


    $comment_arr = explode("|", $comment);
    if($comment_arr[0] != "") {

    // Admin hack part One: Checking if user is registered (appelsinjuice.org)
    $admin_posting = FALSE;
    foreach($all_users as $member_db_line) {
    if(!eregi("<\?",$member_db_line) and $member_db_line != ""){
    $user_arr = explode("|",$member_db_line);
    if(strtolower($user_arr[2]) == strtolower($comment_arr[1]) || strtolower($user_arr[4]) == strtolower($comment_arr[1])) {
    $admin_posting = TRUE;
    }
    }
    }
    // END Admin hack part One

    $comment_arr[4] = stripslashes(rtrim($comment_arr[4]));

    if($comment_arr[2] != "none"){
    if( preg_match("/^[\.A-z0-9_\-]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $comment_arr[2])){ $url_target = "";$mail_or_url = "mailto:"; }
    else{
    $url_target = "";
    $mail_or_url = "";
    if(substr($comment_arr[2],0,3) == "www"){ $mail_or_url = "http://"; }
    }

    $output = str_replace("{author}", "<a $url_target href=\"$mail_or_url".stripslashes($comment_arr[2])."\">".stripslashes($comment_arr[1])."</a>", $template_comment);
    }
    else{ $output = str_replace("{author}", $comment_arr[1], $template_comment); }
    $comment_arr[4] = run_filters('news-comment-content',$comment_arr[4]);
    $output = str_replace("{mail}", "$comment_arr[2]",$output);

    // Show commenters host hack - adding variable {host} (appelsinjuice.org)
    if (!!stristr($output, "{host}")) {
    if ($comment_arr[3] && $comment_arr[3] != "not detected") {
    $hostname = gethostbyaddr($comment_arr[3]);
    $hostname = "*." . substr($hostname, strpos($hostname, ".") + 1);
    $output = str_replace("{host}", $hostname, $output);
    }
    else {
    $output = str_replace("{host}", "no host", $output);
    }
    }
    // END Show commenters host

    $output = str_replace("{music}", "$comment_arr[7]",$output);

    // Admin hack part Two: Adding a template variable (appelsinjuice.org)
    if ($admin_posting == "TRUE") {
    $output = str_replace("{admin}", $config_admin_template,$output); }
    else { $output = str_replace("{admin}", "",$output); }
    // END Admin hack part Two

    $output = str_replace("{date}", date($config_timestamp_comment, $comment_arr[0]),$output);
    $output = str_replace("{date-local}", strftime($config_timestamp_local_comment, $comment_arr[0]), $output);
    $output = str_replace("{comment-id}", $comment_arr[0],$output);
    $comment_arr[4] = preg_replace("/\
    PHP Code:
    (.*)\[\/PHP\]/esiU", "php_string('$1')", $comment_arr[4]);
                        
    $output = str_replace("{comment}", "<a id=\"" ."C" .$comment_arr[0]."\"></a>$comment_arr[4]",$output);
                        
    // {comnum} & altcolors
                        
    if($i%== 0) {
                            
    $com_alternating "cn_comment_odd";
                        }
                        else {
                            
    $com_alternating "cn_comment_even";
                        }
                        
    $output str_replace("{alternating}"$com_alternating$output);
                        
    $i++;

                        
    $output str_replace("{comnum}"$cjnumber$output);
                        if (
    $config_reverse_comments == "yes") {
                            
    $cjnumber--;
                        }
                        else { 
    $cjnumber++; }
                        
    $output run_filters('news-comment',$output);
                        
    $output replace_comment("show"$output);
                        echo 
    $output;

                    }
                }
            }
        }

            
    // Comments Pagination
            
    if ($config_comments_pagination == "Yes") {
                
    $cprev_next_msg $template_cprev_next;
                
    $nextcstart $cstart $cnum;
                
    $prevcstart $cstart $cnum;
                
    $COM_REQUEST_URI $PHP_SELF "?" cute_query_string($QUERY_STRING, array("cstart"));

                
    // <--- Previous
                
    if($cstart>1+$cghost){
                    
    $cprev_next_msg preg_replace("'\[prev-link\](.*?)\[/prev-link\]'si""<a href=\"{$COM_REQUEST_URI}&amp;cstart={$prevcstart}\">\\1</a>"$cprev_next_msg);
                }
                else {
                    
    $cprev_next_msg preg_replace("'\[prev-link\](.*?)\[/prev-link\]'si""\\1"$cprev_next_msg); $no_cprev TRUE;
                }
                
    // |<-- Previous

                // {pages}
                
    $cnumadd 0;
                
    $cpages "";
                for(
    $k=1;$cnumadd<$total_comments;$k++){
                    
    $cstartnum $cnum*($k-1)+1+$cghost;
                    if(
    $cstartnum != $cstart) {
                        
    $cpages .= "<a href=\"{$COM_REQUEST_URI}&amp;cstart={$cstartnum}\">$k</a> ";
                    }
                    else {
                        
    $cpages .= " <strong>| $k |</strong> ";
                    }
                
    $cnumadd $cnum*$k;
                }
                
    $cprev_next_msg str_replace("{pages}"$cpages$cprev_next_msg);
                
    // {pages} |

                // Next -->
                
    if($cstart+$cnum-1-$cghost $total_comments) {
                    
    $cprev_next_msg preg_replace("'\[next-link\](.*?)\[/next-link\]'si""<a href=\"{$COM_REQUEST_URI}&amp;cstart={$nextcstart}\">\\1</a>"$cprev_next_msg);
                }
                else {
                    
    $cprev_next_msg preg_replace("'\[next-link\](.*?)\[/next-link\]'si""\\1"$cprev_next_msg); $no_cnext TRUE;
                }
                
    // Next -->|

                
    if (!$no_cprev or !$no_cnext){ echo $cprev_next_msg; }
            }
            
    // Comments Pagination

        
    $template_form str_replace("{config_http_script_dir}""$config_http_script_dir"$template_form);

        
    $smilies_form "\n<script type=\"text/javascript\">
        //<![CDATA[
        function insertext(text, spot){
        document.forms['comment'].elements['comments'].value += ' ' +text;
        }
        //]]></script>
        "
    .insertSmilies('short'FALSE);

        
    $template_form str_replace("{smilies}"$smilies_form$template_form);
        if (
    $_COOKIE['commentname']) { $template_form str_replace("{savedname}"$_COOKIE['commentname'], $template_form); } else { $template_form str_replace("{savedname}"""$template_form); }
        if (
    $_COOKIE['commentmail']) { $template_form str_replace("{savedmail}"$_COOKIE['commentmail'], $template_form); } else { $template_form str_replace("{savedmail}"""$template_form); }
        
    // rememberme input
        
    $template_form str_replace("{remember}","<input type=\"checkbox\" id=\"rememberme\" name=\"rememberme\" value=\"yes\" checked=\"checked\" />"$template_form);

        echo
    "<form method=\"post\" id=\"comment\" action=\"\">".$template_form."<div><input type=\"hidden\" name=\"javasubaction\" value=\"$subaction\" /><input type=\"hidden\" name=\"subaction\" value=\"addcomment\" /><input type=\"hidden\" name=\"ucat\" value=\"$ucat\" /><input type=\"hidden\" name=\"show\" value=\"$show\" />$user_post_query</div></form>";

    }
    //####################################################################################################################
    //         Active News
    //####################################################################################################################
    if($allow_active_news){

        
    $all_news file("$news_file");

            
    // stupid hack for sorting dates
            // if ($config_sortbydate == "yes") {
            
    asort($all_news);
            
    reset($all_news);
            
    $all_news array_reverse($all_news);
            
    // }

        
    if($reverse == TRUE){ $all_news array_reverse($all_news); }
        
    $all_news run_filters('news-recordset',$all_news);
        
    $count_all 0;
        if(isset(
    $category) and $category != ""){
            foreach(
    $all_news as $news_line){
                
    $news_arr explode("|"$news_line);
                if(
    $requested_cats and $requested_cats[$news_arr[6]] == TRUE){ $count_all ++; }
                else{ continue; }
            }
        }else{ 
    $count_all count($all_news); }
        
    // Sort News v1.0 - End addblock
        
    if (!empty($sortby)) {
        if (!
    function_exists('sortcmp')) {
         function 
    sortcmp($a$b) {
          global 
    $all_news$sortby;

          
    $news_a explode('|'$all_news[$a]);
          
    $news_b explode('|'$all_news[$b]);

          return 
    strnatcasecmp($news_a[$sortby], $news_b[$sortby]);
         }
        }
        
    uksort($all_news'sortcmp');
        unset(
    $sortby);
        }
        
    // Sort News v1.0 - End addblock
        
    $i 0;
        
    $o 0;
        
    $showed 0;
        
    $repeat TRUE;
        
    $url_archive $archive;

        while(
    $repeat != FALSE){

            foreach(
    $all_news as $news_line){

               
    $news_arr explode("|"$news_line);
               
    /*
            // prospective posting
            $nowtime = time() + ($config_date_adjust * 60);
            if (($config_prospective == "On" and $nowtime <= $news_arr[0])) {
            $count_all--;
            continue;
            }*/
            
    $modifier run_filters('news-loop''');

            if (
    $modifier == "skip") {
                
    $count_all--;
                continue;
                }

            if(
    $category and $requested_cats[$news_arr[6]] != TRUE){ continue; }

            if(isset(
    $start_from) and $start_from != ""){
                if(
    $i $start_from){
                    
    $i++;
                    continue; }
                elseif(
    $showed == $number){  break; }
            }

            if(
    $my_names[$news_arr[1]]){ $my_author $my_names[$news_arr[1]]; }
            else{ 
    $my_author $news_arr[1]; }

            
    $output $template_active;
            
    // TEIT highlight-HACK
            
    if($highlight) {
                
    $news_arr[3] = str_replace($highlight"<em>$highlight</em>"$news_arr[3]);
                }
            
    // end teit highlight-hack
            // alternating
            
    if($o%== 0) { $nws_alternating "cn_news_odd"; } else { $nws_alternating "cn_news_even"; }
            
    $output str_replace("{alternating}"$nws_alternating$output);
            
    $o++;
            
    $output str_replace("{title}"$news_arr[2], $output);

            
    // Add DATE variable to active news template
            
    $output str_replace("{date}"date($config_timestamp_active$news_arr[0]), $output);
            
    $output str_replace("{date-local}"strftime($config_timestamp_local_active$news_arr[0]), $output);
            
    // END Add DATE variable to AN
            
    $output str_replace("{author}"$my_author$output);
            if(
    $news_arr[5] != ""){$output str_replace("{avatar}""<img alt=\"\" src=\"$news_arr[5]\" style=\"border: none;\" />"$output); }
            else{ 
    $output str_replace("{avatar}"""$output); }
            
    $output str_replace("{avatar-url}""$news_arr[5]"$output);

        
    // Music hack by rilmith 3 lines below.
        
    if ($news_arr[7] != "") {
        
    $output str_replace("{music}"$news_arr[7], $output); }
        else { 
    $output str_replace("{music}"$config_music_empty$output); }

            
    $output str_replace("[link]","<a title=\"$lang_article_linktext\" href=\"$PHP_SELF?subaction=showfull&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]&amp;$user_query\">"$output);
            
    $output str_replace("[/link]","</a>"$output);
            
    $output str_replace("{comments-num}"countComments($news_arr[0], $archive), $output);
            
    $output str_replace("{short-story}"run_filters('news-entry-content',$news_arr[3]), $output);
            
    $output str_replace("{full-story}"run_filters('news-entry-content',$news_arr[4]), $output);
            
    $output str_replace("{category}"$cat[$news_arr[6]], $output);
            
    $output str_replace("{category-id}"$news_arr[6], $output);
            if(
    $cat_icon[$news_arr[6]] != ""){ $output str_replace("{category-icon}""<img alt=\"".$cat[$news_arr[6]]." icon\" style=\"border: none;\" src=\"".$cat_icon[$news_arr[6]]."\" />"$output); }
            else{ 
    $output str_replace("{category-icon}"""$output); }

            
    $output str_replace("{author-name}"$name_to_nick[$news_arr[1]], $output);

             if(
    $my_mails[$news_arr[1]] != ""){
                 
    $output str_replace("[mail]","<a href=\"mailto:".$my_mails[$news_arr[1]]."\">"$output);
                 
    $output str_replace("[/mail]","</a>"$output);
            }else{
                 
    $output str_replace("[mail]",""$output);
                 
    $output str_replace("[/mail]",""$output);
             }
            
    // RSS
            
    $output str_replace("{rssmail}"$my_mails[$news_arr[1]], $output);
            
    $output str_replace("{rssdate}"date("r"$news_arr[0]), $output);
            
    $output str_replace("{rssauthor}"$news_arr[1], $output);
            
    // end rss
            
    $output str_replace("{news-id}"$news_arr[0], $output);
            
    $output str_replace("{archive-id}"$archive$output);
            
    $output str_replace("{php-self}"$PHP_SELF$output);
            
    $output str_replace("{cute-http-path}"$config_http_script_dir$output);

    // XFields v2.1 - addblock
    $xfieldsaction "templatereplace";
    $xfieldsinput $output;
    $xfieldsid $news_arr[0];
    include(
    "xfields.mdu");
    $output $xfieldsoutput;
    // XFields v2.1 - End addblock

            
    $output run_filters('news-entry',$output);
            
    $output replace_news("show"$output);


            if(
    $news_arr[4] != "" or $action == "showheadlines"){//if full story
                
    if($config_full_popup == "yes"){

                    
    $output preg_replace("/\\[full-link\\]/","<a href=\"#\" onclick=\"window.open('$config_http_script_dir/show_news.php?subaction=showfull&amp;id=$news_arr[0]&amp;archive=$archive&amp;template=$template', '_News', '$config_full_popup_string');return false;\">"$output);
                }else{
                    
    $output str_replace("[full-link]","<a href=\"$PHP_SELF?subaction=showfull&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]&amp;$user_query\">"$output);
                }
                    
    $output str_replace("[/full-link]","</a>"$output);
            }else{
                
    $output preg_replace("'\\[full-link\\].*?\\[/full-link\\]'si","<!-- no full story-->"$output);
            }

    //        $output = run_filters('news-active-comlink', $output);
            
    if($config_comments_popup == "yes"){
                
    $output str_replace("[com-link]","<a href=\"#\" onclick=\"window.open('$config_http_script_dir/show_news.php?subaction=showcomments&amp;template=$template&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]', '_News', '$config_comments_popup_string');return false;\">"$output);
            }else{
                
    $output str_replace("[com-link]","<a href=\"$PHP_SELF?subaction=showcomments&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]&amp;$user_query\">"$output);
            }

            
    $output str_replace("[/com-link]","</a>"$output);

    // AJB Date header option (based on code by SMKILLER2, rescued by The Dude)
    if ($config_date_header == "Yes") {
        if (
    $dateheader_S != date("dmY"$news_arr[0])) {
            
    // 161-hacks above and below
            
    $dateheader_S date("dmY"$news_arr[0]);

             
    $dateheader date($config_date_headerformat$news_arr[0]);
             
    $dateheader_local strftime($config_date_headerformatlocal$news_arr[0]);
             
    $dateheader_p $template_dateheader;
             
    $dateheader_p str_replace("{dateheader}"$dateheader$dateheader_p);
             
    $dateheader_p str_replace("{dateheader-local}"strftime($dateheader_local$news_arr[0]), $dateheader_p);

             echo 
    $dateheader_p;
            }
        }
    // End AJB Date header option



            
    echo $output;
            
    $showed++;
            
    $i++;

            if(
    $number != and $number == $i){ break; }
            }
            
    $used_archives[$archive] = TRUE;
    // Archives Looop
            
    if($i $number and $only_active != TRUE){

                if(!
    $handle opendir("$cutepath/data/archives")){ die("<div style=\"text-align: center;\">$lang_archive_notopen</div>"); }
                     while (
    false !== ($file readdir($handle)))
                     {
                         if(
    $file != "." and $file != ".." and eregi("news.arch"$file))
                         {
                             
    $file_arr explode(".",$file);
                            
    $archives_arr[$file_arr[0]] = $file_arr[0];
                         }
                     }
                
    closedir($handle);

                
    $archives_arr[$in_use]="";
                
    $in_use max($archives_arr);

                if(
    $in_use != "" and !$used_archives[$in_use]){
                    
    $all_news file("$cutepath/data/archives/$in_use.news.arch");
                    
    $archive $in_use;
                    
    $used_archives[$in_use] = TRUE;
                }else{ 
    $repeat FALSE; }

            }else{ 
    $repeat FALSE; }
        }

    // << Previous   &   Next >>

        
    $prev_next_msg $template_prev_next;

        
    //----------------------------------
        // Previous link
        //----------------------------------
        
    if(isset($start_from) and $start_from != "" and $start_from 0){
            
    $prev $start_from $number;
            
    $prev_next_msg preg_replace("'\[prev-link\](.*?)\[/prev-link\]'si""<a href=\"$PHP_SELF?start_from=$prev&amp;archive=$url_archive&amp;subaction=$subaction&amp;id=$id&amp;$user_query\">\\1</a>"$prev_next_msg);
        }else{ 
    $prev_next_msg preg_replace("'\[prev-link\](.*?)\[/prev-link\]'si""\\1"$prev_next_msg); $no_prev TRUE; }

        
    //----------------------------------
        // Pages
        //----------------------------------
        
    if($number){
        
    $pages_count = @ceil($count_all/$number);
        
    $pages_start_from 0;
        
    $pages "";
        for(
    $j=1;$j<=$pages_count;$j++){
            if(
    $pages_start_from != $start_from){ $pages .= "<a href=\"$PHP_SELF?start_from=$pages_start_from&amp;archive=$url_archive&amp;subaction=$subaction&amp;id=$id&amp;$user_query\">$j</a> "; }
            else{ 
    $pages .= " <strong>| $j |</strong> "; }
            
    $pages_start_from += $number;
        }
        
    $prev_next_msg str_replace("{pages}"$pages$prev_next_msg);
        }
        
    //----------------------------------
        // Next link
        //----------------------------------
        
    if($number $count_all and $i $count_all){
            
    $prev_next_msg preg_replace("'\[next-link\](.*?)\[/next-link\]'si""<a href=\"$PHP_SELF?start_from=$i&amp;archive=$url_archive&amp;subaction=$subaction&amp;id=$id&amp;$user_query\">\\1</a>"$prev_next_msg);
        }else{ 
    $prev_next_msg preg_replace("'\[next-link\](.*?)\[/next-link\]'si""\\1"$prev_next_msg); $no_next TRUE;}


        if    (!
    $no_prev or !$no_next){ echo $prev_next_msg; }
    }
    }while(
    0);
    ?> 

  15. #15
    Free Geek computerages's Avatar
    Join Date
    Oct 2004
    Location
    /dev/null
    Posts
    1,071
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    [php]<?PHP

    if (!defined('PLUGIN_FRAMEWORK_VERSION')) {
    include($cutepath.'/inc/plugins.php');
    LoadActivePlugins();
    }

    do{ // Used if we want to display some error to the user and halt the rest of the script



    // [locales] v[1] - addblock
    setlocale (LC_ALL, $config_locale_active);
    // [locales] v[1] - End addblock

    // AJB Visible language addon
    $vis_lang_file = $cutepath . "/inc/lang/" . $config_cn_lang . ".visible.php";
    if (file_exists($vis_lang_file)) {
    include($vis_lang_file);
    }
    // END AJBVISLANGADD

    $user_query = cute_query_string($QUERY_STRING, array("start_from", "archive", "subaction", "id", "ucat"));
    $user_post_query = cute_query_string($QUERY_STRING, array("start_from", "archive", "subaction", "id", "ucat"), "post");

    // [locales] v[1] - addblock
    //############################################################################## ######################################
    // Some localized date setup / Not working ATM
    //############################################################################## ######################################

    if ($config_date_select && $config_date_select != "Other") {
    $config_timestamp_active = $config_date_select;
    }
    // [locales] v[1] - End addblock
    //############################################################################## ######################################
    // Define Categories
    //############################################################################## ######################################
    $cat_lines = file("$cutepath/data/category.db.php");
    foreach($cat_lines as $single_line){
    $cat_arr = explode("|", $single_line);
    $cat[$cat_arr[0]] = $cat_arr[1];
    $cat_icon[$cat_arr[0]]=$cat_arr[2];
    }
    //############################################################################## ######################################
    // Define Users
    //############################################################################## ######################################
    $all_users = file("$cutepath/data/users.db.php");
    foreach($all_users as $user)
    {
    if(!eregi("<\?",$member_db_line)){
    $user_arr = explode("|",$user);
    if($user_arr[4] != "")
    {
    if($user_arr[7] != 1 and $user_arr[5] != ""){ $my_names[$user_arr[2]] = "<a href=\"mailto:$user_arr[5]\">$user_arr[4]</a>"; }
    else{ $my_names[$user_arr[2]] = "$user_arr[4]"; }
    $name_to_nick[$user_arr[2]] = $user_arr[4];
    }
    else
    {
    if($user_arr[7] != 1 and $user_arr[5] != ""){ $my_names[$user_arr[2]] = "<a href=\"mailto:$user_arr[5]\">$user_arr[2]</a>"; }
    else{ $my_names[$user_arr[2]] = "$user_arr[2]"; }
    $name_to_nick[$user_arr[2]] = $user_arr[2];
    }

    if($user_arr[7] != 1){ $my_mails[$user_arr[2]] = $user_arr[5]; }
    else{ $my_mails[$user_arr[2]] = ""; }
    $my_passwords[$user_arr[2]] = $user_arr[3];
    $my_users[] = $user_arr[2];
    }
    }
    //############################################################################## ######################################
    // Add Comment
    //############################################################################## ######################################
    $allow_add_comment = run_filters('news-allow-comment',$allow_add_comment);
    if($allow_add_comment){
    $name = trim($name);

    echo '<script type="text/javascript">

    function setCookie(name, value, expires, path, domain, secure) {
    var curCookie = name + "=" + escape(value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
    document.cookie = curCookie;
    }

    function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
    } else
    begin += 2;
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    end = dc.length;
    return unescape(dc.substring(begin + prefix.length, end));
    }

    function deleteCookie(name, path, domain) {
    if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
    }

    </script>';

    if(isset($HTTP_X_FORWARDED_FOR)){ $ip = $HTTP_X_FORWARDED_FOR; }
    elseif(isset($HTTP_CLIENT_IP)) { $ip = $HTTP_CLIENT_IP; }
    if($ip == "") { $ip = $REMOTE_ADDR; }
    if($ip == "") { $ip = "not detected";}


    // Check Flood Protection
    if($config_flood_time != 0 and $config_flood_time != "" ){
    if(flooder($ip, $id) == TRUE ){
    echo("<div style=\"text-align: center;\">$lang_floodprot</div>");
    $CN_HALT = TRUE;
    break 1;
    }
    }
    // Check if IP is banned

    $blockip = FALSE;
    $old_ips = file("$cutepath/data/ipban.db.php");
    $new_ips = fopen("$cutepath/data/ipban.db.php", "w");
    @flock ($new_ips,2);
    foreach($old_ips as $old_ip_line){
    $ip_arr = explode("|", $old_ip_line);
    // AJ-FORK allow blocking of incomplete IPs
    if(!stristr($ip, $ip_arr[0])){
    // Oldstatement
    // $ip_arr[0] != $ip //
    fwrite($new_ips, $old_ip_line);
    }else{
    $countblocks = $ip_arr[1] = $ip_arr[1] + 1;
    fwrite($new_ips, "$ip_arr[0]|$countblocks||\n"); $blockip = TRUE;
    }
    }
    @flock ($new_ips,3);
    fclose($new_ips);
    if($blockip){
    echo("<div style=\"text-align: center;\">$lang_blocked</div>");
    $CN_HALT = TRUE;
    break 1;
    }

    // Check if name is Protected
    $is_member = FALSE;
    foreach($all_users as $member_db_line)
    {
    if(!eregi("<\?",$member_db_line) and $member_db_line != ""){
    $user_arr = explode("|",$member_db_line);

    //if the name is protected
    if((strtolower($user_arr[2]) == strtolower($name) or strtolower($user_arr[4]) == strtolower($name)) and $user_arr[3] != md5(md5($password)) and $name != "")
    {
    $comments = preg_replace(array("'\"'", "'\''", "''"), array("&quot;", "'", ""), $comments);
    $name = replace_comment("add", preg_replace("/\n/", "",$name));
    $mail = replace_comment("add", preg_replace("/\n/", "",$mail));

    echo"<div style=\"text-align: center;\">$lang_commentregistered<br />
    <form method=\"post\" action=\"\">
    <input type=\"password\" name=\"password\" />
    <input type=\"hidden\" name=\"name\" value=\"$name\" />
    <input type=\"hidden\" name=\"comments\" value=\"$comments\" />
    <input type=\"hidden\" name=\"mail\" value=\"$mail\" />
    <input type=\"hidden\" name=\"ip\" value=\"$ip\" />
    <input type=\"hidden\" name=\"subaction\" value=\"addcomment\" />
    <input type=\"hidden\" name=\"javasubaction\" value=\"$javasubaction\" />
    <input type=\"hidden\" name=\"show\" value=\"$show\" />
    <input type=\"hidden\" name=\"ucat\" value=\"$ucat\" />
    <input type=\"hidden\" name=\"rememberme\" value=\"$rememberme\" />
    $user_post_query
    <input type=\"submit\" value=\"$lang_commentregisteredbutton\"/></form></div>";
    $CN_HALT = TRUE;
    break 2;
    // exit();
    }

    if(strtolower($user_arr[2]) == strtolower($name)) $is_member = TRUE;
    }
    }

    // Check if only members can post comments
    if($config_only_registered_comment == "yes" and !$is_member){
    echo"<div style=\"text-align: center;\">$lang_onlyregistered</div>";
    $CN_HALT = TRUE;
    break 1;
    }

    //* Wrap long words
    if($config_auto_wrap > 1){
    $comments_arr = explode("\n", $comments);
    foreach($comments_arr as $line){
    $wraped_comm .= ereg_replace("([^ \/\/]{".$config_auto_wrap."})","\\1\n", $line) ."\n";
    }
    if(strlen($name) > $config_auto_wrap){ $name = substr($name, 0, $config_auto_wrap)." ..."; }
    $comments = $wraped_comm;
    }
    //*/

    $comments = replace_comment("add", run_filters('news-posted-comment-content',$comments));
    $name = replace_comment("add", preg_replace("/\n/", "",$name));
    $mail = replace_comment("add", preg_replace("/\n/", "",$mail));

    if($name == " " or $name == ""){
    echo("<div style=\"text-align: center;\">$lang_comment_needname</div>");
    $CN_HALT = TRUE;
    break 1;
    }
    if($mail == " " or $mail == ""){ $mail = "none"; }
    else{ $ok = FALSE;
    if(preg_match("/^[\.A-z0-9_\-]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $mail)) $ok = TRUE;
    elseif($config_allow_url_instead_mail == "yes" and preg_match("/((http(s?):\/\/)|(www\.))([\w\.]+)([\/\w+\.-?]+)/", $mail)) $ok = TRUE;
    elseif($config_allow_url_instead_mail != "yes"){
    echo("<div style=\"text-align: center;\">$lang_comment_invalidmail</div>");
    $CN_HALT = TRUE;
    break 1;
    }
    else{
    echo("<div style=\"text-align: center;\">$lang_comment_needvalidmail</div>");
    $CN_HALT = TRUE;
    break 1;
    }
    }

    if($comments == ""){
    echo("<div style=\"text-align: center;\">$lang_comment_notblank</div>");
    $CN_HALT = TRUE;
    break 1;
    }

    $time = time()+($config_date_adjust*60);

    // Add the Comment
    $old_comments = file("$comm_file");
    $new_comments = fopen("$comm_file", "w");
    @flock ($new_comments,2);
    $found = FALSE;
    foreach($old_comments as $old_comments_line)
    {
    $old_comments_arr = explode("|>|", $old_comments_line);
    if($old_comments_arr[0] == $id)
    {
    $old_comments_arr[1] = trim($old_comments_arr[1]);
    fwrite($new_comments, "$old_comments_arr[0]|>|$old_comments_arr[1]$time|$name|$mail|$ip|$comments||\n");
    $found = TRUE;
    }else{
    fwrite($new_comments, $old_comments_line);
    }
    }
    if(!$found){ fwrite($new_comments, "$id|>|$time|$name|$mail|$ip|$comments||\n"); }
    @flock ($new_comments,3);
    fclose($new_comments);

    // Add Flood Protection
    if($config_flood_time != "0" and $config_flood_time != "" ){

    $flood_file = fopen("$cutepath/data/flood.db.php", "a");
    @flock ($flood_file,2);
    fwrite($flood_file, time()."|$ip|$id|\n");
    @flock ($flood_file,3);
    fclose($flood_file);
    }
    // Sort problems with browser refresh posting comments twice + remembermefeature

    if ($rememberme == "yes") {
    echo "
    <script type=\"text/javascript\">
    var now = new Date();
    now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
    setCookie(\"commentname\", \"$name\", now);
    setCookie(\"commentmail\", \"$mail\", now);
    </script>";
    }
    else {
    echo "
    <script type=\"text/javascript\">
    var now = new Date();
    now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
    deleteCookie(\"commentname\");
    deleteCookie(\"commentmail\");
    </script>";
    }


    echo "
    <!-- Javascript redirect -->
    <script type=\"text/javascript\">self.location.href='http://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}?subaction=$javasubaction&id=$id&archive=$archive&start_from=$start_from&ucat=$ucat&$user_query';</script>";
    }
    //############################################################################## ######################################
    // Show Full Story
    //############################################################################## ######################################
    if($allow_full_story){
    $all_active_news = file("$news_file");

    foreach($all_active_news as $active_news)
    {
    $news_arr = explode("|", $active_news);

    if($news_arr[0] == $id and (!$catid or $catid == $news_arr[6]))
    {
    run_actions('news-fullstory-page');

    $found = TRUE;
    if($news_arr[4] == "" and (!eregi("\{short-story\}", $template_full)) ){ $news_arr[4] = $news_arr[3]; }

    if($my_names[$news_arr[1]]){ $my_author = $my_names[$news_arr[1]]; }
    else{ $my_author = $news_arr[1]; }
    $output = $template_full;
    $output = run_filters('news-show-generic', $output);
    $output = str_replace("{title}", $news_arr[2], $output);
    $output = str_replace("{date}", date($config_timestamp_active, $news_arr[0]), $output);
    // Add DATE variable to full story template
    $output = str_replace("{date-local}", strftime($config_timestamp_local_active, $news_arr[0]), $output);
    // END Add DATE variable FS
    $output = str_replace("{author}", $my_author, $output);

    // TEIT highlight-HACK
    if($highlight) {
    $news_arr[3] = str_replace($highlight, "<em>$highlight</em>", $news_arr[3]);
    $news_arr[4] = str_replace($highlight, "<em>$highlight</em>", $news_arr[4]);
    }
    // end teit highlight-hack

    $output = str_replace("{short-story}", run_filters('news-entry-content',$news_arr[3]), $output);
    $output = str_replace("{full-story}", run_filters('news-entry-content',$news_arr[4]), $output);
    if($news_arr[5] != ""){$output = str_replace("{avatar}", "<img alt=\"\" src=\"$news_arr[5]\" style=\"border: none;\" />", $output); }
    else{ $output = str_replace("{avatar}", "", $output); }
    $output = str_replace("{avatar-url}", "$news_arr[5]", $output);

    // Music hack by rilmith 3 lines below.
    if ($news_arr[7] != "") {
    $output = str_replace("{music}", $news_arr[7], $output); }
    else { $output = str_replace("{music}", $config_music_empty, $output); }

    $output = str_replace("{comments-num}", countComments($news_arr[0], $archive), $output);
    $output = str_replace("{category}", $cat[$news_arr[6]], $output);
    $output = str_replace("{category-id}", $news_arr[6], $output);
    if($cat_icon[$news_arr[6]] != ""){ $output = str_replace("{category-icon}", "<img style=\"border: none;\" alt=\"".$cat[$news_arr[6]]." icon\" src=\"".$cat_icon[$news_arr[6]]."\" />", $output); }
    else{ $output = str_replace("{category-icon}", "", $output); }

    if($config_comments_popup == "yes"){
    $output = str_replace("[com-link]","<a href=\"#\" onclick=\"window.open('$config_http_script_dir/show_news.php?subaction=showcomments&amp;template=$template&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]', '_News', '$config_comments_popup_string');return false;\">", $output);
    }else{
    $output = str_replace("[com-link]","<a href=\"$PHP_SELF?subaction=showcomments&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]&amp;$user_query\">", $output);
    }
    $output = str_replace("[/com-link]","</a>", $output);
    $output = str_replace("{author-name}", $name_to_nick[$news_arr[1]], $output);

    if($my_mails[$news_arr[1]] != ""){
    $output = str_replace("[mail]","<a href=\"mailto:".$my_mails[$news_arr[1]]."\">", $output);
    $output = str_replace("[/mail]","</a>", $output);
    }else{
    $output = str_replace("[mail]","", $output);
    $output = str_replace("[/mail]","", $output);
    }
    $output = str_replace("{news-id}", $news_arr[0], $output);
    $output = str_replace("{archive-id}", $archive, $output);
    $output = str_replace("{php-self}", $PHP_SELF, $output);
    $output = str_replace("{cute-http-path}", $config_http_script_dir, $output);

    // XFields v2.1 - addblock
    $xfieldsaction = "templatereplace";
    $xfieldsinput = $output;
    $xfieldsid = $news_arr[0];
    include("xfields.mdu");
    $output = $xfieldsoutput;
    // XFields v2.1 - End addblock

    $output = run_filters('news-entry',$output);

    $output = replace_news("show", $output);

    echo $output;
    $allow_comments = run_filters('news-show-comments', $allow_comments);
    }
    }
    if(!$found){
    echo("<div style=\"text-align: center;\">$lang_article_notfound</div>");
    $CN_HALT = TRUE;
    break 1;
    }
    }
    //############################################################################## ######################################
    // Show Comments
    //############################################################################## ######################################
    if($allow_comments){
    $all_comments = file("$comm_file");

    foreach($all_comments as $comment_line)
    {

    $comment_line = trim($comment_line);
    $comment_line_arr = explode("|>|", $comment_line);
    if($id == $comment_line_arr[0])
    {
    $individual_comments = explode("||", $comment_line_arr[1]);
    // Comments Pagination
    if($config_reverse_comments == "yes"){
    $individual_comments = array_reverse($individual_comments);
    $cghost = 1;} else {$cghost = 0;}
    $total_comments = count($individual_comments)-1;
    // Comments Pagination

    // {comnum} (a bloody mess that doesn't make sense this early in the morning!)
    $i = 0;
    if ($config_reverse_comments == "yes") {
    $cjnumber = $total_comments;
    if ($cstart) { $cjnumber -= $cstart -2; }
    }
    else { $cjnumber = 1;
    if ($cstart) { $cjnumber += $cstart -1;}
    }

    foreach($individual_comments as $comment)
    {

    // Comments Pagination
    if ($config_comments_pagination == "Yes") {
    $comment_index++;

    !isset($cnum) and $cnum = $config_comments_pagination_number;
    $cstart < 1 and $cstart = 1+$cghost;

    if ($comment_index < $cstart) continue;
    if ($comment_index >= $cstart + $cnum) break;
    }
    // Comments Pagination


    $comment_arr = explode("|", $comment);
    if($comment_arr[0] != "") {

    // Admin hack part One: Checking if user is registered (appelsinjuice.org)
    $admin_posting = FALSE;
    foreach($all_users as $member_db_line) {
    if(!eregi("<\?",$member_db_line) and $member_db_line != ""){
    $user_arr = explode("|",$member_db_line);
    if(strtolower($user_arr[2]) == strtolower($comment_arr[1]) || strtolower($user_arr[4]) == strtolower($comment_arr[1])) {
    $admin_posting = TRUE;
    }
    }
    }
    // END Admin hack part One

    $comment_arr[4] = stripslashes(rtrim($comment_arr[4]));

    if($comment_arr[2] != "none"){
    if( preg_match("/^[\.A-z0-9_\-]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $comment_arr[2])){ $url_target = "";$mail_or_url = "mailto:"; }
    else{
    $url_target = "";
    $mail_or_url = "";
    if(substr($comment_arr[2],0,3) == "www"){ $mail_or_url = "http://"; }
    }

    $output = str_replace("{author}", "<a $url_target href=\"$mail_or_url".stripslashes($comment_arr[2])."\">".stripslashes($comment_arr[1])."</a>", $template_comment);
    }
    else{ $output = str_replace("{author}", $comment_arr[1], $template_comment); }
    $comment_arr[4] = run_filters('news-comment-content',$comment_arr[4]);
    $output = str_replace("{mail}", "$comment_arr[2]",$output);

    // Show commenters host hack - adding variable {host} (appelsinjuice.org)
    if (!!stristr($output, "{host}")) {
    if ($comment_arr[3] && $comment_arr[3] != "not detected") {
    $hostname = gethostbyaddr($comment_arr[3]);
    $hostname = "*." . substr($hostname, strpos($hostname, ".") + 1);
    $output = str_replace("{host}", $hostname, $output);
    }
    else {
    $output = str_replace("{host}", "no host", $output);
    }
    }
    // END Show commenters host

    $output = str_replace("{music}", "$comment_arr[7]",$output);

    // Admin hack part Two: Adding a template variable (appelsinjuice.org)
    if ($admin_posting == "TRUE") {
    $output = str_replace("{admin}", $config_admin_template,$output); }
    else { $output = str_replace("{admin}", "",$output); }
    // END Admin hack part Two

    $output = str_replace("{date}", date($config_timestamp_comment, $comment_arr[0]),$output);
    $output = str_replace("{date-local}", strftime($config_timestamp_local_comment, $comment_arr[0]), $output);
    $output = str_replace("{comment-id}", $comment_arr[0],$output);
    $comment_arr[4] = preg_replace("/\
    PHP Code:
    (.*)\[\/PHP\]/esiU", "php_string('$1')", $comment_arr[4]);
                        
    $output = str_replace("{comment}", "<a id=\"" ."C" .$comment_arr[0]."\"></a>$comment_arr[4]",$output);
                        
    // {comnum} & altcolors
                        
    if($i%== 0) {
                            
    $com_alternating "cn_comment_odd";
                        }
                        else {
                            
    $com_alternating "cn_comment_even";
                        }
                        
    $output str_replace("{alternating}"$com_alternating$output);
                        
    $i++;

                        
    $output str_replace("{comnum}"$cjnumber$output);
                        if (
    $config_reverse_comments == "yes") {
                            
    $cjnumber--;
                        }
                        else { 
    $cjnumber++; }
                        
    $output run_filters('news-comment',$output);
                        
    $output replace_comment("show"$output);
                        echo 
    $output;

                    }
                }
            }
        }

            
    // Comments Pagination
            
    if ($config_comments_pagination == "Yes") {
                
    $cprev_next_msg $template_cprev_next;
                
    $nextcstart $cstart $cnum;
                
    $prevcstart $cstart $cnum;
                
    $COM_REQUEST_URI $PHP_SELF "?" cute_query_string($QUERY_STRING, array("cstart"));

                
    // <--- Previous
                
    if($cstart>1+$cghost){
                    
    $cprev_next_msg preg_replace("'\[prev-link\](.*?)\[/prev-link\]'si""<a href=\"{$COM_REQUEST_URI}&amp;cstart={$prevcstart}\">\\1</a>"$cprev_next_msg);
                }
                else {
                    
    $cprev_next_msg preg_replace("'\[prev-link\](.*?)\[/prev-link\]'si""\\1"$cprev_next_msg); $no_cprev TRUE;
                }
                
    // |<-- Previous

                // {pages}
                
    $cnumadd 0;
                
    $cpages "";
                for(
    $k=1;$cnumadd<$total_comments;$k++){
                    
    $cstartnum $cnum*($k-1)+1+$cghost;
                    if(
    $cstartnum != $cstart) {
                        
    $cpages .= "<a href=\"{$COM_REQUEST_URI}&amp;cstart={$cstartnum}\">$k</a> ";
                    }
                    else {
                        
    $cpages .= " <strong>| $k |</strong> ";
                    }
                
    $cnumadd $cnum*$k;
                }
                
    $cprev_next_msg str_replace("{pages}"$cpages$cprev_next_msg);
                
    // {pages} |

                // Next -->
                
    if($cstart+$cnum-1-$cghost $total_comments) {
                    
    $cprev_next_msg preg_replace("'\[next-link\](.*?)\[/next-link\]'si""<a href=\"{$COM_REQUEST_URI}&amp;cstart={$nextcstart}\">\\1</a>"$cprev_next_msg);
                }
                else {
                    
    $cprev_next_msg preg_replace("'\[next-link\](.*?)\[/next-link\]'si""\\1"$cprev_next_msg); $no_cnext TRUE;
                }
                
    // Next -->|

                
    if (!$no_cprev or !$no_cnext){ echo $cprev_next_msg; }
            }
            
    // Comments Pagination

        
    $template_form str_replace("{config_http_script_dir}""$config_http_script_dir"$template_form);

        
    $smilies_form "\n<script type=\"text/javascript\">
        //<![CDATA[
        function insertext(text, spot){
        document.forms['comment'].elements['comments'].value += ' ' +text;
        }
        //]]></script>
        "
    .insertSmilies('short'FALSE);

        
    $template_form str_replace("{smilies}"$smilies_form$template_form);
        if (
    $_COOKIE['commentname']) { $template_form str_replace("{savedname}"$_COOKIE['commentname'], $template_form); } else { $template_form str_replace("{savedname}"""$template_form); }
        if (
    $_COOKIE['commentmail']) { $template_form str_replace("{savedmail}"$_COOKIE['commentmail'], $template_form); } else { $template_form str_replace("{savedmail}"""$template_form); }
        
    // rememberme input
        
    $template_form str_replace("{remember}","<input type=\"checkbox\" id=\"rememberme\" name=\"rememberme\" value=\"yes\" checked=\"checked\" />"$template_form);

        echo
    "<form method=\"post\" id=\"comment\" action=\"\">".$template_form."<div><input type=\"hidden\" name=\"javasubaction\" value=\"$subaction\" /><input type=\"hidden\" name=\"subaction\" value=\"addcomment\" /><input type=\"hidden\" name=\"ucat\" value=\"$ucat\" /><input type=\"hidden\" name=\"show\" value=\"$show\" />$user_post_query</div></form>";

    }



    ///////////////////////////////////////////////////////
    // Function:     cute_query_string
    // Description: Format the Query_String for CuteNews purpuses index.php?

    function cute_query_string($q_string$strips$type="get"){
        foreach(
    $strips as $key){
            
    $strips[$key] = TRUE;
        }
        
    $var_value explode("&"$q_string);

        foreach(
    $var_value as $var_peace){
            
    $parts explode("="$var_peace);
            if(
    $strips[$parts[0]] != TRUE and $parts[0] != ""){
                if(
    $type == "post"){
                    
    $my_q .= "<input type=\"hidden\" name=\"".$parts[0]."\" value=\"".$parts[1]."\" />\n";
                }else{
                    
    $my_q .= "$var_peace&amp;";
                }
            }
        }

    if( 
    substr($my_q, -5) == "&amp;" ){ $my_q substr($my_q0, -5); }

    return 
    $my_q;
    }


    //##############################################################################  ######################################
    //         Active News
    //##############################################################################  ######################################
    if($allow_active_news){

        
    $all_news file("$news_file");

            
    // stupid hack for sorting dates
            // if ($config_sortbydate == "yes") {
            
    asort($all_news);
            
    reset($all_news);
            
    $all_news array_reverse($all_news);
            
    // }

        
    if($reverse == TRUE){ $all_news array_reverse($all_news); }
        
    $all_news run_filters('news-recordset',$all_news);
        
    $count_all 0;
        if(isset(
    $category) and $category != ""){
            foreach(
    $all_news as $news_line){
                
    $news_arr explode("|"$news_line);
                if(
    $requested_cats and $requested_cats[$news_arr[6]] == TRUE){ $count_all ++; }
                else{ continue; }
            }
        }else{ 
    $count_all count($all_news); }
        
    // Sort News v1.0 - End addblock
        
    if (!empty($sortby)) {
        if (!
    function_exists('sortcmp')) {
         function 
    sortcmp($a$b) {
          global 
    $all_news$sortby;

          
    $news_a explode('|'$all_news[$a]);
          
    $news_b explode('|'$all_news[$b]);

          return 
    strnatcasecmp($news_a[$sortby], $news_b[$sortby]);
         }
        }
        
    uksort($all_news'sortcmp');
        unset(
    $sortby);
        }
        
    // Sort News v1.0 - End addblock
        
    $i 0;
        
    $o 0;
        
    $showed 0;
        
    $repeat TRUE;
        
    $url_archive $archive;

        while(
    $repeat != FALSE){

            foreach(
    $all_news as $news_line){

               
    $news_arr explode("|"$news_line);
               
    /*
            // prospective posting
            $nowtime = time() + ($config_date_adjust * 60);
            if (($config_prospective == "On" and $nowtime <= $news_arr[0])) {
            $count_all--;
            continue;
            }*/
            
    $modifier run_filters('news-loop''');

            if (
    $modifier == "skip") {
                
    $count_all--;
                continue;
                }

            if(
    $category and $requested_cats[$news_arr[6]] != TRUE){ continue; }

            if(isset(
    $start_from) and $start_from != ""){
                if(
    $i $start_from){
                    
    $i++;
                    continue; }
                elseif(
    $showed == $number){  break; }
            }

            if(
    $my_names[$news_arr[1]]){ $my_author $my_names[$news_arr[1]]; }
            else{ 
    $my_author $news_arr[1]; }

            
    $output $template_active;
            
    // TEIT highlight-HACK
            
    if($highlight) {
                
    $news_arr[3] = str_replace($highlight"<em>$highlight</em>"$news_arr[3]);
                }
            
    // end teit highlight-hack
            // alternating
            
    if($o%== 0) { $nws_alternating "cn_news_odd"; } else { $nws_alternating "cn_news_even"; }
            
    $output str_replace("{alternating}"$nws_alternating$output);
            
    $o++;
            
    $output str_replace("{title}"$news_arr[2], $output);

            
    // Add DATE variable to active news template
            
    $output str_replace("{date}"date($config_timestamp_active$news_arr[0]), $output);
            
    $output str_replace("{date-local}"strftime($config_timestamp_local_active$news_arr[0]), $output);
            
    // END Add DATE variable to AN
            
    $output str_replace("{author}"$my_author$output);
            if(
    $news_arr[5] != ""){$output str_replace("{avatar}""<img alt=\"\" src=\"$news_arr[5]\" style=\"border: none;\" />"$output); }
            else{ 
    $output str_replace("{avatar}"""$output); }
            
    $output str_replace("{avatar-url}""$news_arr[5]"$output);

        
    // Music hack by rilmith 3 lines below.
        
    if ($news_arr[7] != "") {
        
    $output str_replace("{music}"$news_arr[7], $output); }
        else { 
    $output str_replace("{music}"$config_music_empty$output); }

            
    $output str_replace("[link]","<a title=\"$lang_article_linktext\" href=\"$PHP_SELF?subaction=showfull&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]&amp;$user_query\">"$output);
            
    $output str_replace("[/link]","</a>"$output);
            
    $output str_replace("{comments-num}"countComments($news_arr[0], $archive), $output);
            
    $output str_replace("{short-story}"run_filters('news-entry-content',$news_arr[3]), $output);
            
    $output str_replace("{full-story}"run_filters('news-entry-content',$news_arr[4]), $output);
            
    $output str_replace("{category}"$cat[$news_arr[6]], $output);
            
    $output str_replace("{category-id}"$news_arr[6], $output);
            if(
    $cat_icon[$news_arr[6]] != ""){ $output str_replace("{category-icon}""<img alt=\"".$cat[$news_arr[6]]." icon\" style=\"border: none;\" src=\"".$cat_icon[$news_arr[6]]."\" />"$output); }
            else{ 
    $output str_replace("{category-icon}"""$output); }

            
    $output str_replace("{author-name}"$name_to_nick[$news_arr[1]], $output);

             if(
    $my_mails[$news_arr[1]] != ""){
                 
    $output str_replace("[mail]","<a href=\"mailto:".$my_mails[$news_arr[1]]."\">"$output);
                 
    $output str_replace("[/mail]","</a>"$output);
            }else{
                 
    $output str_replace("[mail]",""$output);
                 
    $output str_replace("[/mail]",""$output);
             }
            
    // RSS
            
    $output str_replace("{rssmail}"$my_mails[$news_arr[1]], $output);
            
    $output str_replace("{rssdate}"date("r"$news_arr[0]), $output);
            
    $output str_replace("{rssauthor}"$news_arr[1], $output);
            
    // end rss
            
    $output str_replace("{news-id}"$news_arr[0], $output);
            
    $output str_replace("{archive-id}"$archive$output);
            
    $output str_replace("{php-self}"$PHP_SELF$output);
            
    $output str_replace("{cute-http-path}"$config_http_script_dir$output);

    // XFields v2.1 - addblock
    $xfieldsaction "templatereplace";
    $xfieldsinput $output;
    $xfieldsid $news_arr[0];
    include(
    "xfields.mdu");
    $output $xfieldsoutput;
    // XFields v2.1 - End addblock

            
    $output run_filters('news-entry',$output);
            
    $output replace_news("show"$output);


            if(
    $news_arr[4] != "" or $action == "showheadlines"){//if full story
                
    if($config_full_popup == "yes"){

                    
    $output preg_replace("/\\[full-link\\]/","<a href=\"#\" onclick=\"window.open('$config_http_script_dir/show_news.php?subaction=showfull&amp;id=$news_arr[0]&amp;archive=$archive&amp;template=$template', '_News', '$config_full_popup_string');return false;\">"$output);
                }else{
                    
    $output str_replace("[full-link]","<a href=\"$PHP_SELF?subaction=showfull&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]&amp;$user_query\">"$output);
                }
                    
    $output str_replace("[/full-link]","</a>"$output);
            }else{
                
    $output preg_replace("'\\[full-link\\].*?\\[/full-link\\]'si","<!-- no full story-->"$output);
            }

    //        $output = run_filters('news-active-comlink', $output);
            
    if($config_comments_popup == "yes"){
                
    $output str_replace("[com-link]","<a href=\"#\" onclick=\"window.open('$config_http_script_dir/show_news.php?subaction=showcomments&amp;template=$template&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]', '_News', '$config_comments_popup_string');return false;\">"$output);
            }else{
                
    $output str_replace("[com-link]","<a href=\"$PHP_SELF?subaction=showcomments&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]&amp;$user_query\">"$output);
            }

            
    $output str_replace("[/com-link]","</a>"$output);

    // AJB Date header option (based on code by SMKILLER2, rescued by The Dude)
    if ($config_date_header == "Yes") {
        if (
    $dateheader_S != date("dmY"$news_arr[0])) {
            
    // 161-hacks above and below
            
    $dateheader_S date("dmY"$news_arr[0]);

            
    $dateheader date($config_date_headerformat$news_arr[0]);
            
    $dateheader_local strftime($config_date_headerformatlocal$news_arr[0]);
            
    $dateheader_p $template_dateheader;
            
    $dateheader_p str_replace("{dateheader}"$dateheader$dateheader_p);
            
    $dateheader_p str_replace("{dateheader-local}"strftime($dateheader_local$news_arr[0]), $dateheader_p);

             echo 
    $dateheader_p;
            }
        }
    // End AJB Date header option



            
    echo $output;
            
    $showed++;
            
    $i++;

            if(
    $number != and $number == $i){ break; }
            }
            
    $used_archives[$archive] = TRUE;
    // Archives Looop
            
    if($i $number and $only_active != TRUE){

                if(!
    $handle opendir("$cutepath/data/archives")){ die("<div style=\"text-align: center;\">$lang_archive_notopen</div>"); }
                     while (
    false !== ($file readdir($handle)))
                     {
                         if(
    $file != "." and $file != ".." and eregi("news.arch"$file))
                         {
                             
    $file_arr explode(".",$file);
                            
    $archives_arr[$file_arr[0]] = $file_arr[0];
                         }
                     }
                
    closedir($handle);

                
    $archives_arr[$in_use]="";
                
    $in_use max($archives_arr);

                if(
    $in_use != "" and !$used_archives[$in_use]){
                    
    $all_news file("$cutepath/data/archives/$in_use.news.arch");
                    
    $archive $in_use;
                    
    $used_archives[$in_use] = TRUE;
                }else{ 
    $repeat FALSE; }

            }else{ 
    $repeat FALSE; }
        }

    // << Previous   &   Next >>

        
    $prev_next_msg $template_prev_next;

        
    //----------------------------------
        // Previous link
        //----------------------------------
        
    if(isset($start_from) and $start_from != "" and $start_from 0){
            
    $prev $start_from $number;
            
    $prev_next_msg preg_replace("'\[prev-link\](.*?)\[/prev-link\]'si""<a href=\"$PHP_SELF?start_from=$prev&amp;archive=$url_archive&amp;subaction=$subaction&amp;id=$id&amp;$u  ser_query\">\\1</a>"$prev_next_msg);
        }else{ 
    $prev_next_msg preg_replace("'\[prev-link\](.*?)\[/prev-link\]'si""\\1"$prev_next_msg); $no_prev TRUE; }

        
    //----------------------------------
        // Pages
        //----------------------------------
        
    if($number){
        
    $pages_count = @ceil($count_all/$number);
        
    $pages_start_from 0;
        
    $pages "";
        for(
    $j=1;$j<=$pages_count;$j++){
            if(
    $pages_start_from != $start_from){ $pages .= "<a href=\"$PHP_SELF?start_from=$pages_start_from&amp;archive=$url_archive&amp;subaction=$subacti  on&amp;id=$id&amp;$user_query\">$j</a> "; }
            else{ 
    $pages .= " <strong>| $j |</strong> "; }
            
    $pages_start_from += $number;
        }
        
    $prev_next_msg str_replace("{pages}"$pages$prev_next_msg);
        }
        
    //----------------------------------
        // Next link
        //----------------------------------
        
    if($number $count_all and $i $count_all){
            
    $prev_next_msg preg_replace("'\[next-link\](.*?)\[/next-link\]'si""<a href=\"$PHP_SELF?start_from=$i&amp;archive=$url_archive&amp;subaction=$subaction&amp;id=$id&amp;$user  _query\">\\1</a>"$prev_next_msg);
        }else{ 
    $prev_next_msg preg_replace("'\[next-link\](.*?)\[/next-link\]'si""\\1"$prev_next_msg); $no_next TRUE;}


        if    (!
    $no_prev or !$no_next){ echo $prev_next_msg; }
    }
    }while(
    0);
    ?> 

  16. #16
    SitePoint Enthusiast Anders N's Avatar
    Join Date
    Dec 2004
    Location
    Norway
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did you change anything? I get the excact same message.

  17. #17
    Free Geek computerages's Avatar
    Join Date
    Oct 2004
    Location
    /dev/null
    Posts
    1,071
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Anders N
    Did you change anything? I get the excact same message.
    yea i did make some changes, anyway try this one out, it should work or you will get another error:

    [php]
    <?PHP

    if (!defined('PLUGIN_FRAMEWORK_VERSION')) {
    include($cutepath.'/inc/plugins.php');
    LoadActivePlugins();
    }

    do{ // Used if we want to display some error to the user and halt the rest of the script



    ///////////////////////////////////////////////////////
    // Function: cute_query_string
    // Description: Format the Query_String for CuteNews purpuses index.php?

    function cute_query_string($q_string, $strips, $type="get"){
    foreach($strips as $key){
    $strips[$key] = TRUE;
    }
    $var_value = explode("&", $q_string);

    foreach($var_value as $var_peace){
    $parts = explode("=", $var_peace);
    if($strips[$parts[0]] != TRUE and $parts[0] != ""){
    if($type == "post"){
    $my_q .= "<input type=\"hidden\" name=\"".$parts[0]."\" value=\"".$parts[1]."\" />\n";
    }else{
    $my_q .= "$var_peace&amp;";
    }
    }
    }




    // [locales] v[1] - addblock
    setlocale (LC_ALL, $config_locale_active);
    // [locales] v[1] - End addblock

    // AJB Visible language addon
    $vis_lang_file = $cutepath . "/inc/lang/" . $config_cn_lang . ".visible.php";
    if (file_exists($vis_lang_file)) {
    include($vis_lang_file);
    }
    // END AJBVISLANGADD

    $user_query = cute_query_string($QUERY_STRING, array("start_from", "archive", "subaction", "id", "ucat"));
    $user_post_query = cute_query_string($QUERY_STRING, array("start_from", "archive", "subaction", "id", "ucat"), "post");

    // [locales] v[1] - addblock
    //############################################################################## ######################################
    // Some localized date setup / Not working ATM
    //############################################################################## ######################################

    if ($config_date_select && $config_date_select != "Other") {
    $config_timestamp_active = $config_date_select;
    }
    // [locales] v[1] - End addblock
    //############################################################################## ######################################
    // Define Categories
    //############################################################################## ######################################
    $cat_lines = file("$cutepath/data/category.db.php");
    foreach($cat_lines as $single_line){
    $cat_arr = explode("|", $single_line);
    $cat[$cat_arr[0]] = $cat_arr[1];
    $cat_icon[$cat_arr[0]]=$cat_arr[2];
    }
    //############################################################################## ######################################
    // Define Users
    //############################################################################## ######################################
    $all_users = file("$cutepath/data/users.db.php");
    foreach($all_users as $user)
    {
    if(!eregi("<\?",$member_db_line)){
    $user_arr = explode("|",$user);
    if($user_arr[4] != "")
    {
    if($user_arr[7] != 1 and $user_arr[5] != ""){ $my_names[$user_arr[2]] = "<a href=\"mailto:$user_arr[5]\">$user_arr[4]</a>"; }
    else{ $my_names[$user_arr[2]] = "$user_arr[4]"; }
    $name_to_nick[$user_arr[2]] = $user_arr[4];
    }
    else
    {
    if($user_arr[7] != 1 and $user_arr[5] != ""){ $my_names[$user_arr[2]] = "<a href=\"mailto:$user_arr[5]\">$user_arr[2]</a>"; }
    else{ $my_names[$user_arr[2]] = "$user_arr[2]"; }
    $name_to_nick[$user_arr[2]] = $user_arr[2];
    }

    if($user_arr[7] != 1){ $my_mails[$user_arr[2]] = $user_arr[5]; }
    else{ $my_mails[$user_arr[2]] = ""; }
    $my_passwords[$user_arr[2]] = $user_arr[3];
    $my_users[] = $user_arr[2];
    }
    }
    //############################################################################## ######################################
    // Add Comment
    //############################################################################## ######################################
    $allow_add_comment = run_filters('news-allow-comment',$allow_add_comment);
    if($allow_add_comment){
    $name = trim($name);

    echo '<script type="text/javascript">

    function setCookie(name, value, expires, path, domain, secure) {
    var curCookie = name + "=" + escape(value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
    document.cookie = curCookie;
    }

    function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
    } else
    begin += 2;
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    end = dc.length;
    return unescape(dc.substring(begin + prefix.length, end));
    }

    function deleteCookie(name, path, domain) {
    if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
    }

    </script>';

    if(isset($HTTP_X_FORWARDED_FOR)){ $ip = $HTTP_X_FORWARDED_FOR; }
    elseif(isset($HTTP_CLIENT_IP)) { $ip = $HTTP_CLIENT_IP; }
    if($ip == "") { $ip = $REMOTE_ADDR; }
    if($ip == "") { $ip = "not detected";}


    // Check Flood Protection
    if($config_flood_time != 0 and $config_flood_time != "" ){
    if(flooder($ip, $id) == TRUE ){
    echo("<div style=\"text-align: center;\">$lang_floodprot</div>");
    $CN_HALT = TRUE;
    break 1;
    }
    }
    // Check if IP is banned

    $blockip = FALSE;
    $old_ips = file("$cutepath/data/ipban.db.php");
    $new_ips = fopen("$cutepath/data/ipban.db.php", "w");
    @flock ($new_ips,2);
    foreach($old_ips as $old_ip_line){
    $ip_arr = explode("|", $old_ip_line);
    // AJ-FORK allow blocking of incomplete IPs
    if(!stristr($ip, $ip_arr[0])){
    // Oldstatement
    // $ip_arr[0] != $ip //
    fwrite($new_ips, $old_ip_line);
    }else{
    $countblocks = $ip_arr[1] = $ip_arr[1] + 1;
    fwrite($new_ips, "$ip_arr[0]|$countblocks||\n"); $blockip = TRUE;
    }
    }
    @flock ($new_ips,3);
    fclose($new_ips);
    if($blockip){
    echo("<div style=\"text-align: center;\">$lang_blocked</div>");
    $CN_HALT = TRUE;
    break 1;
    }

    // Check if name is Protected
    $is_member = FALSE;
    foreach($all_users as $member_db_line)
    {
    if(!eregi("<\?",$member_db_line) and $member_db_line != ""){
    $user_arr = explode("|",$member_db_line);

    //if the name is protected
    if((strtolower($user_arr[2]) == strtolower($name) or strtolower($user_arr[4]) == strtolower($name)) and $user_arr[3] != md5(md5($password)) and $name != "")
    {
    $comments = preg_replace(array("'\"'", "'\''", "''"), array("&quot;", "'", ""), $comments);
    $name = replace_comment("add", preg_replace("/\n/", "",$name));
    $mail = replace_comment("add", preg_replace("/\n/", "",$mail));

    echo"<div style=\"text-align: center;\">$lang_commentregistered<br />
    <form method=\"post\" action=\"\">
    <input type=\"password\" name=\"password\" />
    <input type=\"hidden\" name=\"name\" value=\"$name\" />
    <input type=\"hidden\" name=\"comments\" value=\"$comments\" />
    <input type=\"hidden\" name=\"mail\" value=\"$mail\" />
    <input type=\"hidden\" name=\"ip\" value=\"$ip\" />
    <input type=\"hidden\" name=\"subaction\" value=\"addcomment\" />
    <input type=\"hidden\" name=\"javasubaction\" value=\"$javasubaction\" />
    <input type=\"hidden\" name=\"show\" value=\"$show\" />
    <input type=\"hidden\" name=\"ucat\" value=\"$ucat\" />
    <input type=\"hidden\" name=\"rememberme\" value=\"$rememberme\" />
    $user_post_query
    <input type=\"submit\" value=\"$lang_commentregisteredbutton\"/></form></div>";
    $CN_HALT = TRUE;
    break 2;
    // exit();
    }

    if(strtolower($user_arr[2]) == strtolower($name)) $is_member = TRUE;
    }
    }

    // Check if only members can post comments
    if($config_only_registered_comment == "yes" and !$is_member){
    echo"<div style=\"text-align: center;\">$lang_onlyregistered</div>";
    $CN_HALT = TRUE;
    break 1;
    }

    //* Wrap long words
    if($config_auto_wrap > 1){
    $comments_arr = explode("\n", $comments);
    foreach($comments_arr as $line){
    $wraped_comm .= ereg_replace("([^ \/\/]{".$config_auto_wrap."})","\\1\n", $line) ."\n";
    }
    if(strlen($name) > $config_auto_wrap){ $name = substr($name, 0, $config_auto_wrap)." ..."; }
    $comments = $wraped_comm;
    }
    //*/

    $comments = replace_comment("add", run_filters('news-posted-comment-content',$comments));
    $name = replace_comment("add", preg_replace("/\n/", "",$name));
    $mail = replace_comment("add", preg_replace("/\n/", "",$mail));

    if($name == " " or $name == ""){
    echo("<div style=\"text-align: center;\">$lang_comment_needname</div>");
    $CN_HALT = TRUE;
    break 1;
    }
    if($mail == " " or $mail == ""){ $mail = "none"; }
    else{ $ok = FALSE;
    if(preg_match("/^[\.A-z0-9_\-]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $mail)) $ok = TRUE;
    elseif($config_allow_url_instead_mail == "yes" and preg_match("/((http(s?):\/\/)|(www\.))([\w\.]+)([\/\w+\.-?]+)/", $mail)) $ok = TRUE;
    elseif($config_allow_url_instead_mail != "yes"){
    echo("<div style=\"text-align: center;\">$lang_comment_invalidmail</div>");
    $CN_HALT = TRUE;
    break 1;
    }
    else{
    echo("<div style=\"text-align: center;\">$lang_comment_needvalidmail</div>");
    $CN_HALT = TRUE;
    break 1;
    }
    }

    if($comments == ""){
    echo("<div style=\"text-align: center;\">$lang_comment_notblank</div>");
    $CN_HALT = TRUE;
    break 1;
    }

    $time = time()+($config_date_adjust*60);

    // Add the Comment
    $old_comments = file("$comm_file");
    $new_comments = fopen("$comm_file", "w");
    @flock ($new_comments,2);
    $found = FALSE;
    foreach($old_comments as $old_comments_line)
    {
    $old_comments_arr = explode("|>|", $old_comments_line);
    if($old_comments_arr[0] == $id)
    {
    $old_comments_arr[1] = trim($old_comments_arr[1]);
    fwrite($new_comments, "$old_comments_arr[0]|>|$old_comments_arr[1]$time|$name|$mail|$ip|$comments||\n");
    $found = TRUE;
    }else{
    fwrite($new_comments, $old_comments_line);
    }
    }
    if(!$found){ fwrite($new_comments, "$id|>|$time|$name|$mail|$ip|$comments||\n"); }
    @flock ($new_comments,3);
    fclose($new_comments);

    // Add Flood Protection
    if($config_flood_time != "0" and $config_flood_time != "" ){

    $flood_file = fopen("$cutepath/data/flood.db.php", "a");
    @flock ($flood_file,2);
    fwrite($flood_file, time()."|$ip|$id|\n");
    @flock ($flood_file,3);
    fclose($flood_file);
    }
    // Sort problems with browser refresh posting comments twice + remembermefeature

    if ($rememberme == "yes") {
    echo "
    <script type=\"text/javascript\">
    var now = new Date();
    now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
    setCookie(\"commentname\", \"$name\", now);
    setCookie(\"commentmail\", \"$mail\", now);
    </script>";
    }
    else {
    echo "
    <script type=\"text/javascript\">
    var now = new Date();
    now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
    deleteCookie(\"commentname\");
    deleteCookie(\"commentmail\");
    </script>";
    }


    echo "
    <!-- Javascript redirect -->
    <script type=\"text/javascript\">self.location.href='http://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}?subaction=$javasubaction&id=$id&archive=$archive&start_from=$start_from&ucat=$ucat&$user_query';</script>";
    }
    //############################################################################## ######################################
    // Show Full Story
    //############################################################################## ######################################
    if($allow_full_story){
    $all_active_news = file("$news_file");

    foreach($all_active_news as $active_news)
    {
    $news_arr = explode("|", $active_news);

    if($news_arr[0] == $id and (!$catid or $catid == $news_arr[6]))
    {
    run_actions('news-fullstory-page');

    $found = TRUE;
    if($news_arr[4] == "" and (!eregi("\{short-story\}", $template_full)) ){ $news_arr[4] = $news_arr[3]; }

    if($my_names[$news_arr[1]]){ $my_author = $my_names[$news_arr[1]]; }
    else{ $my_author = $news_arr[1]; }
    $output = $template_full;
    $output = run_filters('news-show-generic', $output);
    $output = str_replace("{title}", $news_arr[2], $output);
    $output = str_replace("{date}", date($config_timestamp_active, $news_arr[0]), $output);
    // Add DATE variable to full story template
    $output = str_replace("{date-local}", strftime($config_timestamp_local_active, $news_arr[0]), $output);
    // END Add DATE variable FS
    $output = str_replace("{author}", $my_author, $output);

    // TEIT highlight-HACK
    if($highlight) {
    $news_arr[3] = str_replace($highlight, "<em>$highlight</em>", $news_arr[3]);
    $news_arr[4] = str_replace($highlight, "<em>$highlight</em>", $news_arr[4]);
    }
    // end teit highlight-hack

    $output = str_replace("{short-story}", run_filters('news-entry-content',$news_arr[3]), $output);
    $output = str_replace("{full-story}", run_filters('news-entry-content',$news_arr[4]), $output);
    if($news_arr[5] != ""){$output = str_replace("{avatar}", "<img alt=\"\" src=\"$news_arr[5]\" style=\"border: none;\" />", $output); }
    else{ $output = str_replace("{avatar}", "", $output); }
    $output = str_replace("{avatar-url}", "$news_arr[5]", $output);

    // Music hack by rilmith 3 lines below.
    if ($news_arr[7] != "") {
    $output = str_replace("{music}", $news_arr[7], $output); }
    else { $output = str_replace("{music}", $config_music_empty, $output); }

    $output = str_replace("{comments-num}", countComments($news_arr[0], $archive), $output);
    $output = str_replace("{category}", $cat[$news_arr[6]], $output);
    $output = str_replace("{category-id}", $news_arr[6], $output);
    if($cat_icon[$news_arr[6]] != ""){ $output = str_replace("{category-icon}", "<img style=\"border: none;\" alt=\"".$cat[$news_arr[6]]." icon\" src=\"".$cat_icon[$news_arr[6]]."\" />", $output); }
    else{ $output = str_replace("{category-icon}", "", $output); }

    if($config_comments_popup == "yes"){
    $output = str_replace("[com-link]","<a href=\"#\" onclick=\"window.open('$config_http_script_dir/show_news.php?subaction=showcomments&amp;template=$template&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]', '_News', '$config_comments_popup_string');return false;\">", $output);
    }else{
    $output = str_replace("[com-link]","<a href=\"$PHP_SELF?subaction=showcomments&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]&amp;$user_query\">", $output);
    }
    $output = str_replace("[/com-link]","</a>", $output);
    $output = str_replace("{author-name}", $name_to_nick[$news_arr[1]], $output);

    if($my_mails[$news_arr[1]] != ""){
    $output = str_replace("[mail]","<a href=\"mailto:".$my_mails[$news_arr[1]]."\">", $output);
    $output = str_replace("[/mail]","</a>", $output);
    }else{
    $output = str_replace("[mail]","", $output);
    $output = str_replace("[/mail]","", $output);
    }
    $output = str_replace("{news-id}", $news_arr[0], $output);
    $output = str_replace("{archive-id}", $archive, $output);
    $output = str_replace("{php-self}", $PHP_SELF, $output);
    $output = str_replace("{cute-http-path}", $config_http_script_dir, $output);

    // XFields v2.1 - addblock
    $xfieldsaction = "templatereplace";
    $xfieldsinput = $output;
    $xfieldsid = $news_arr[0];
    include("xfields.mdu");
    $output = $xfieldsoutput;
    // XFields v2.1 - End addblock

    $output = run_filters('news-entry',$output);

    $output = replace_news("show", $output);

    echo $output;
    $allow_comments = run_filters('news-show-comments', $allow_comments);
    }
    }
    if(!$found){
    echo("<div style=\"text-align: center;\">$lang_article_notfound</div>");
    $CN_HALT = TRUE;
    break 1;
    }
    }
    //############################################################################## ######################################
    // Show Comments
    //############################################################################## ######################################
    if($allow_comments){
    $all_comments = file("$comm_file");

    foreach($all_comments as $comment_line)
    {

    $comment_line = trim($comment_line);
    $comment_line_arr = explode("|>|", $comment_line);
    if($id == $comment_line_arr[0])
    {
    $individual_comments = explode("||", $comment_line_arr[1]);
    // Comments Pagination
    if($config_reverse_comments == "yes"){
    $individual_comments = array_reverse($individual_comments);
    $cghost = 1;} else {$cghost = 0;}
    $total_comments = count($individual_comments)-1;
    // Comments Pagination

    // {comnum} (a bloody mess that doesn't make sense this early in the morning!)
    $i = 0;
    if ($config_reverse_comments == "yes") {
    $cjnumber = $total_comments;
    if ($cstart) { $cjnumber -= $cstart -2; }
    }
    else { $cjnumber = 1;
    if ($cstart) { $cjnumber += $cstart -1;}
    }

    foreach($individual_comments as $comment)
    {

    // Comments Pagination
    if ($config_comments_pagination == "Yes") {
    $comment_index++;

    !isset($cnum) and $cnum = $config_comments_pagination_number;
    $cstart < 1 and $cstart = 1+$cghost;

    if ($comment_index < $cstart) continue;
    if ($comment_index >= $cstart + $cnum) break;
    }
    // Comments Pagination


    $comment_arr = explode("|", $comment);
    if($comment_arr[0] != "") {

    // Admin hack part One: Checking if user is registered (appelsinjuice.org)
    $admin_posting = FALSE;
    foreach($all_users as $member_db_line) {
    if(!eregi("<\?",$member_db_line) and $member_db_line != ""){
    $user_arr = explode("|",$member_db_line);
    if(strtolower($user_arr[2]) == strtolower($comment_arr[1]) || strtolower($user_arr[4]) == strtolower($comment_arr[1])) {
    $admin_posting = TRUE;
    }
    }
    }
    // END Admin hack part One

    $comment_arr[4] = stripslashes(rtrim($comment_arr[4]));

    if($comment_arr[2] != "none"){
    if( preg_match("/^[\.A-z0-9_\-]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $comment_arr[2])){ $url_target = "";$mail_or_url = "mailto:"; }
    else{
    $url_target = "";
    $mail_or_url = "";
    if(substr($comment_arr[2],0,3) == "www"){ $mail_or_url = "http://"; }
    }

    $output = str_replace("{author}", "<a $url_target href=\"$mail_or_url".stripslashes($comment_arr[2])."\">".stripslashes($comment_arr[1])."</a>", $template_comment);
    }
    else{ $output = str_replace("{author}", $comment_arr[1], $template_comment); }
    $comment_arr[4] = run_filters('news-comment-content',$comment_arr[4]);
    $output = str_replace("{mail}", "$comment_arr[2]",$output);

    // Show commenters host hack - adding variable {host} (appelsinjuice.org)
    if (!!stristr($output, "{host}")) {
    if ($comment_arr[3] && $comment_arr[3] != "not detected") {
    $hostname = gethostbyaddr($comment_arr[3]);
    $hostname = "*." . substr($hostname, strpos($hostname, ".") + 1);
    $output = str_replace("{host}", $hostname, $output);
    }
    else {
    $output = str_replace("{host}", "no host", $output);
    }
    }
    // END Show commenters host

    $output = str_replace("{music}", "$comment_arr[7]",$output);

    // Admin hack part Two: Adding a template variable (appelsinjuice.org)
    if ($admin_posting == "TRUE") {
    $output = str_replace("{admin}", $config_admin_template,$output); }
    else { $output = str_replace("{admin}", "",$output); }
    // END Admin hack part Two

    $output = str_replace("{date}", date($config_timestamp_comment, $comment_arr[0]),$output);
    $output = str_replace("{date-local}", strftime($config_timestamp_local_comment, $comment_arr[0]), $output);
    $output = str_replace("{comment-id}", $comment_arr[0],$output);
    $comment_arr[4] = preg_replace("/\
    PHP Code:
    (.*)\[\/PHP\]/esiU", "php_string('$1')", $comment_arr[4]);
                        
    $output = str_replace("{comment}", "<a id=\"" ."C" .$comment_arr[0]."\"></a>$comment_arr[4]",$output);
                        
    // {comnum} & altcolors
                        
    if($i%== 0) {
                            
    $com_alternating "cn_comment_odd";
                        }
                        else {
                            
    $com_alternating "cn_comment_even";
                        }
                        
    $output str_replace("{alternating}"$com_alternating$output);
                        
    $i++;

                        
    $output str_replace("{comnum}"$cjnumber$output);
                        if (
    $config_reverse_comments == "yes") {
                            
    $cjnumber--;
                        }
                        else { 
    $cjnumber++; }
                        
    $output run_filters('news-comment',$output);
                        
    $output replace_comment("show"$output);
                        echo 
    $output;

                    }
                }
            }
        }

            
    // Comments Pagination
            
    if ($config_comments_pagination == "Yes") {
                
    $cprev_next_msg $template_cprev_next;
                
    $nextcstart $cstart $cnum;
                
    $prevcstart $cstart $cnum;
                
    $COM_REQUEST_URI $PHP_SELF "?" cute_query_string($QUERY_STRING, array("cstart"));

                
    // <--- Previous
                
    if($cstart>1+$cghost){
                    
    $cprev_next_msg preg_replace("'\[prev-link\](.*?)\[/prev-link\]'si""<a href=\"{$COM_REQUEST_URI}&amp;cstart={$prevcstart}\">\\1</a>"$cprev_next_msg);
                }
                else {
                    
    $cprev_next_msg preg_replace("'\[prev-link\](.*?)\[/prev-link\]'si""\\1"$cprev_next_msg); $no_cprev TRUE;
                }
                
    // |<-- Previous

                // {pages}
                
    $cnumadd 0;
                
    $cpages "";
                for(
    $k=1;$cnumadd<$total_comments;$k++){
                    
    $cstartnum $cnum*($k-1)+1+$cghost;
                    if(
    $cstartnum != $cstart) {
                        
    $cpages .= "<a href=\"{$COM_REQUEST_URI}&amp;cstart={$cstartnum}\">$k</a> ";
                    }
                    else {
                        
    $cpages .= " <strong>| $k |</strong> ";
                    }
                
    $cnumadd $cnum*$k;
                }
                
    $cprev_next_msg str_replace("{pages}"$cpages$cprev_next_msg);
                
    // {pages} |

                // Next -->
                
    if($cstart+$cnum-1-$cghost $total_comments) {
                    
    $cprev_next_msg preg_replace("'\[next-link\](.*?)\[/next-link\]'si""<a href=\"{$COM_REQUEST_URI}&amp;cstart={$nextcstart}\">\\1</a>"$cprev_next_msg);
                }
                else {
                    
    $cprev_next_msg preg_replace("'\[next-link\](.*?)\[/next-link\]'si""\\1"$cprev_next_msg); $no_cnext TRUE;
                }
                
    // Next -->|

                
    if (!$no_cprev or !$no_cnext){ echo $cprev_next_msg; }
            }
            
    // Comments Pagination

        
    $template_form str_replace("{config_http_script_dir}""$config_http_script_dir"$template_form);

        
    $smilies_form "\n<script type=\"text/javascript\">
        //<![CDATA[
        function insertext(text, spot){
        document.forms['comment'].elements['comments'].value += ' ' +text;
        }
        //]]></script>
        "
    .insertSmilies('short'FALSE);

        
    $template_form str_replace("{smilies}"$smilies_form$template_form);
        if (
    $_COOKIE['commentname']) { $template_form str_replace("{savedname}"$_COOKIE['commentname'], $template_form); } else { $template_form str_replace("{savedname}"""$template_form); }
        if (
    $_COOKIE['commentmail']) { $template_form str_replace("{savedmail}"$_COOKIE['commentmail'], $template_form); } else { $template_form str_replace("{savedmail}"""$template_form); }
        
    // rememberme input
        
    $template_form str_replace("{remember}","<input type=\"checkbox\" id=\"rememberme\" name=\"rememberme\" value=\"yes\" checked=\"checked\" />"$template_form);

        echo
    "<form method=\"post\" id=\"comment\" action=\"\">".$template_form."<div><input type=\"hidden\" name=\"javasubaction\" value=\"$subaction\" /><input type=\"hidden\" name=\"subaction\" value=\"addcomment\" /><input type=\"hidden\" name=\"ucat\" value=\"$ucat\" /><input type=\"hidden\" name=\"show\" value=\"$show\" />$user_post_query</div></form>";

    }





    if( 
    substr($my_q, -5) == "&amp;" ){ $my_q substr($my_q0, -5); }

    return 
    $my_q;
    }


    //##############################################################################  ######################################
    //         Active News
    //##############################################################################  ######################################
    if($allow_active_news){

        
    $all_news file("$news_file");

            
    // stupid hack for sorting dates
            // if ($config_sortbydate == "yes") {
            
    asort($all_news);
            
    reset($all_news);
            
    $all_news array_reverse($all_news);
            
    // }

        
    if($reverse == TRUE){ $all_news array_reverse($all_news); }
        
    $all_news run_filters('news-recordset',$all_news);
        
    $count_all 0;
        if(isset(
    $category) and $category != ""){
            foreach(
    $all_news as $news_line){
                
    $news_arr explode("|"$news_line);
                if(
    $requested_cats and $requested_cats[$news_arr[6]] == TRUE){ $count_all ++; }
                else{ continue; }
            }
        }else{ 
    $count_all count($all_news); }
        
    // Sort News v1.0 - End addblock
        
    if (!empty($sortby)) {
        if (!
    function_exists('sortcmp')) {
         function 
    sortcmp($a$b) {
          global 
    $all_news$sortby;

          
    $news_a explode('|'$all_news[$a]);
          
    $news_b explode('|'$all_news[$b]);

          return 
    strnatcasecmp($news_a[$sortby], $news_b[$sortby]);
         }
        }
        
    uksort($all_news'sortcmp');
        unset(
    $sortby);
        }
        
    // Sort News v1.0 - End addblock
        
    $i 0;
        
    $o 0;
        
    $showed 0;
        
    $repeat TRUE;
        
    $url_archive $archive;

        while(
    $repeat != FALSE){

            foreach(
    $all_news as $news_line){

               
    $news_arr explode("|"$news_line);
               
    /*
            // prospective posting
            $nowtime = time() + ($config_date_adjust * 60);
            if (($config_prospective == "On" and $nowtime <= $news_arr[0])) {
            $count_all--;
            continue;
            }*/
            
    $modifier run_filters('news-loop''');

            if (
    $modifier == "skip") {
                
    $count_all--;
                continue;
                }

            if(
    $category and $requested_cats[$news_arr[6]] != TRUE){ continue; }

            if(isset(
    $start_from) and $start_from != ""){
                if(
    $i $start_from){
                    
    $i++;
                    continue; }
                elseif(
    $showed == $number){  break; }
            }

            if(
    $my_names[$news_arr[1]]){ $my_author $my_names[$news_arr[1]]; }
            else{ 
    $my_author $news_arr[1]; }

            
    $output $template_active;
            
    // TEIT highlight-HACK
            
    if($highlight) {
                
    $news_arr[3] = str_replace($highlight"<em>$highlight</em>"$news_arr[3]);
                }
            
    // end teit highlight-hack
            // alternating
            
    if($o%== 0) { $nws_alternating "cn_news_odd"; } else { $nws_alternating "cn_news_even"; }
            
    $output str_replace("{alternating}"$nws_alternating$output);
            
    $o++;
            
    $output str_replace("{title}"$news_arr[2], $output);

            
    // Add DATE variable to active news template
            
    $output str_replace("{date}"date($config_timestamp_active$news_arr[0]), $output);
            
    $output str_replace("{date-local}"strftime($config_timestamp_local_active$news_arr[0]), $output);
            
    // END Add DATE variable to AN
            
    $output str_replace("{author}"$my_author$output);
            if(
    $news_arr[5] != ""){$output str_replace("{avatar}""<img alt=\"\" src=\"$news_arr[5]\" style=\"border: none;\" />"$output); }
            else{ 
    $output str_replace("{avatar}"""$output); }
            
    $output str_replace("{avatar-url}""$news_arr[5]"$output);

        
    // Music hack by rilmith 3 lines below.
        
    if ($news_arr[7] != "") {
        
    $output str_replace("{music}"$news_arr[7], $output); }
        else { 
    $output str_replace("{music}"$config_music_empty$output); }

            
    $output str_replace("[link]","<a title=\"$lang_article_linktext\" href=\"$PHP_SELF?subaction=showfull&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]&amp;$user_query\">"$output);
            
    $output str_replace("[/link]","</a>"$output);
            
    $output str_replace("{comments-num}"countComments($news_arr[0], $archive), $output);
            
    $output str_replace("{short-story}"run_filters('news-entry-content',$news_arr[3]), $output);
            
    $output str_replace("{full-story}"run_filters('news-entry-content',$news_arr[4]), $output);
            
    $output str_replace("{category}"$cat[$news_arr[6]], $output);
            
    $output str_replace("{category-id}"$news_arr[6], $output);
            if(
    $cat_icon[$news_arr[6]] != ""){ $output str_replace("{category-icon}""<img alt=\"".$cat[$news_arr[6]]." icon\" style=\"border: none;\" src=\"".$cat_icon[$news_arr[6]]."\" />"$output); }
            else{ 
    $output str_replace("{category-icon}"""$output); }

            
    $output str_replace("{author-name}"$name_to_nick[$news_arr[1]], $output);

             if(
    $my_mails[$news_arr[1]] != ""){
                 
    $output str_replace("[mail]","<a href=\"mailto:".$my_mails[$news_arr[1]]."\">"$output);
                 
    $output str_replace("[/mail]","</a>"$output);
            }else{
                 
    $output str_replace("[mail]",""$output);
                 
    $output str_replace("[/mail]",""$output);
             }
            
    // RSS
            
    $output str_replace("{rssmail}"$my_mails[$news_arr[1]], $output);
            
    $output str_replace("{rssdate}"date("r"$news_arr[0]), $output);
            
    $output str_replace("{rssauthor}"$news_arr[1], $output);
            
    // end rss
            
    $output str_replace("{news-id}"$news_arr[0], $output);
            
    $output str_replace("{archive-id}"$archive$output);
            
    $output str_replace("{php-self}"$PHP_SELF$output);
            
    $output str_replace("{cute-http-path}"$config_http_script_dir$output);

    // XFields v2.1 - addblock
    $xfieldsaction "templatereplace";
    $xfieldsinput $output;
    $xfieldsid $news_arr[0];
    include(
    "xfields.mdu");
    $output $xfieldsoutput;
    // XFields v2.1 - End addblock

            
    $output run_filters('news-entry',$output);
            
    $output replace_news("show"$output);


            if(
    $news_arr[4] != "" or $action == "showheadlines"){//if full story
                
    if($config_full_popup == "yes"){

                    
    $output preg_replace("/\\[full-link\\]/","<a href=\"#\" onclick=\"window.open('$config_http_script_dir/show_news.php?subaction=showfull&amp;id=$news_arr[0]&amp;archive=$archive&amp;template=$template', '_News', '$config_full_popup_string');return false;\">"$output);
                }else{
                    
    $output str_replace("[full-link]","<a href=\"$PHP_SELF?subaction=showfull&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]&amp;$user_query\">"$output);
                }
                    
    $output str_replace("[/full-link]","</a>"$output);
            }else{
                
    $output preg_replace("'\\[full-link\\].*?\\[/full-link\\]'si","<!-- no full story-->"$output);
            }

    //        $output = run_filters('news-active-comlink', $output);
            
    if($config_comments_popup == "yes"){
                
    $output str_replace("[com-link]","<a href=\"#\" onclick=\"window.open('$config_http_script_dir/show_news.php?subaction=showcomments&amp;template=$template&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]', '_News', '$config_comments_popup_string');return false;\">"$output);
            }else{
                
    $output str_replace("[com-link]","<a href=\"$PHP_SELF?subaction=showcomments&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]&amp;$user_query\">"$output);
            }

            
    $output str_replace("[/com-link]","</a>"$output);

    // AJB Date header option (based on code by SMKILLER2, rescued by The Dude)
    if ($config_date_header == "Yes") {
        if (
    $dateheader_S != date("dmY"$news_arr[0])) {
            
    // 161-hacks above and below
            
    $dateheader_S date("dmY"$news_arr[0]);

            
    $dateheader date($config_date_headerformat$news_arr[0]);
            
    $dateheader_local strftime($config_date_headerformatlocal$news_arr[0]);
            
    $dateheader_p $template_dateheader;
            
    $dateheader_p str_replace("{dateheader}"$dateheader$dateheader_p);
            
    $dateheader_p str_replace("{dateheader-local}"strftime($dateheader_local$news_arr[0]), $dateheader_p);

             echo 
    $dateheader_p;
            }
        }
    // End AJB Date header option



            
    echo $output;
            
    $showed++;
            
    $i++;

            if(
    $number != and $number == $i){ break; }
            }
            
    $used_archives[$archive] = TRUE;
    // Archives Looop
            
    if($i $number and $only_active != TRUE){

                if(!
    $handle opendir("$cutepath/data/archives")){ die("<div style=\"text-align: center;\">$lang_archive_notopen</div>"); }
                     while (
    false !== ($file readdir($handle)))
                     {
                         if(
    $file != "." and $file != ".." and eregi("news.arch"$file))
                         {
                             
    $file_arr explode(".",$file);
                            
    $archives_arr[$file_arr[0]] = $file_arr[0];
                         }
                     }
                
    closedir($handle);

                
    $archives_arr[$in_use]="";
                
    $in_use max($archives_arr);

                if(
    $in_use != "" and !$used_archives[$in_use]){
                    
    $all_news file("$cutepath/data/archives/$in_use.news.arch");
                    
    $archive $in_use;
                    
    $used_archives[$in_use] = TRUE;
                }else{ 
    $repeat FALSE; }

            }else{ 
    $repeat FALSE; }
        }

    // << Previous   &   Next >>

        
    $prev_next_msg $template_prev_next;

        
    //----------------------------------
        // Previous link
        //----------------------------------
        
    if(isset($start_from) and $start_from != "" and $start_from 0){
            
    $prev $start_from $number;
            
    $prev_next_msg preg_replace("'\[prev-link\](.*?)\[/prev-link\]'si""<a href=\"$PHP_SELF?start_from=$prev&amp;archive=$url_archive&amp;subaction=$subaction&amp;id=$id&amp;$u  ser_query\">\\1</a>"$prev_next_msg);
        }else{ 
    $prev_next_msg preg_replace("'\[prev-link\](.*?)\[/prev-link\]'si""\\1"$prev_next_msg); $no_prev TRUE; }

        
    //----------------------------------
        // Pages
        //----------------------------------
        
    if($number){
        
    $pages_count = @ceil($count_all/$number);
        
    $pages_start_from 0;
        
    $pages "";
        for(
    $j=1;$j<=$pages_count;$j++){
            if(
    $pages_start_from != $start_from){ $pages .= "<a href=\"$PHP_SELF?start_from=$pages_start_from&amp;archive=$url_archive&amp;subaction=$subacti  on&amp;id=$id&amp;$user_query\">$j</a> "; }
            else{ 
    $pages .= " <strong>| $j |</strong> "; }
            
    $pages_start_from += $number;
        }
        
    $prev_next_msg str_replace("{pages}"$pages$prev_next_msg);
        }
        
    //----------------------------------
        // Next link
        //----------------------------------
        
    if($number $count_all and $i $count_all){
            
    $prev_next_msg preg_replace("'\[next-link\](.*?)\[/next-link\]'si""<a href=\"$PHP_SELF?start_from=$i&amp;archive=$url_archive&amp;subaction=$subaction&amp;id=$id&amp;$user  _query\">\\1</a>"$prev_next_msg);
        }else{ 
    $prev_next_msg preg_replace("'\[next-link\](.*?)\[/next-link\]'si""\\1"$prev_next_msg); $no_next TRUE;}


        if    (!
    $no_prev or !$no_next){ echo $prev_next_msg; }
    }
    }while(
    0);
    ?> 

  18. #18
    SitePoint Enthusiast Anders N's Avatar
    Join Date
    Dec 2004
    Location
    Norway
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Fatal error: Call to undefined function: countcomments() in /usr/home/web/wno32422/ringetoner/inc/shows.inc.php on line 725

  19. #19
    Free Geek computerages's Avatar
    Join Date
    Oct 2004
    Location
    /dev/null
    Posts
    1,071
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Anders N
    Fatal error: Call to undefined function: countcomments() in /usr/home/web/wno32422/ringetoner/inc/shows.inc.php on line 725
    [php]<?PHP

    if (!defined('PLUGIN_FRAMEWORK_VERSION')) {
    include($cutepath.'/inc/plugins.php');
    LoadActivePlugins();
    }

    do{ // Used if we want to display some error to the user and halt the rest of the script




    ////////////////////////////////////////////////////////
    // Function: CountComments
    // Description: Count how many comments belong to a specific article

    function CountComments($id, $archive = FALSE){

    global $cutepath;

    if($cutepath == ""){ $cutepath = "."; }
    $result = "0";
    if($archive){ $all_comments = file("$cutepath/data/archives/${archive}.comments.arch"); }
    else{ $all_comments = file("$cutepath/data/comments.txt"); }

    foreach($all_comments as $comment_line)
    {
    $comment_arr_1 = explode("|>|", $comment_line);
    if($comment_arr_1[0] == $id)
    {
    $comment_arr_2 = explode("||", $comment_arr_1[1]);
    $result = count($comment_arr_2)-1;

    }
    }

    return $result;
    }




    ///////////////////////////////////////////////////////
    // Function: cute_query_string
    // Description: Format the Query_String for CuteNews purpuses index.php?

    function cute_query_string($q_string, $strips, $type="get"){
    foreach($strips as $key){
    $strips[$key] = TRUE;
    }
    $var_value = explode("&", $q_string);

    foreach($var_value as $var_peace){
    $parts = explode("=", $var_peace);
    if($strips[$parts[0]] != TRUE and $parts[0] != ""){
    if($type == "post"){
    $my_q .= "<input type=\"hidden\" name=\"".$parts[0]."\" value=\"".$parts[1]."\" />\n";
    }else{
    $my_q .= "$var_peace&amp;";
    }
    }
    }








    // [locales] v[1] - addblock
    setlocale (LC_ALL, $config_locale_active);
    // [locales] v[1] - End addblock

    // AJB Visible language addon
    $vis_lang_file = $cutepath . "/inc/lang/" . $config_cn_lang . ".visible.php";
    if (file_exists($vis_lang_file)) {
    include($vis_lang_file);
    }
    // END AJBVISLANGADD

    $user_query = cute_query_string($QUERY_STRING, array("start_from", "archive", "subaction", "id", "ucat"));
    $user_post_query = cute_query_string($QUERY_STRING, array("start_from", "archive", "subaction", "id", "ucat"), "post");

    // [locales] v[1] - addblock
    //############################################################################## ######################################
    // Some localized date setup / Not working ATM
    //############################################################################## ######################################

    if ($config_date_select && $config_date_select != "Other") {
    $config_timestamp_active = $config_date_select;
    }
    // [locales] v[1] - End addblock
    //############################################################################## ######################################
    // Define Categories
    //############################################################################## ######################################
    $cat_lines = file("$cutepath/data/category.db.php");
    foreach($cat_lines as $single_line){
    $cat_arr = explode("|", $single_line);
    $cat[$cat_arr[0]] = $cat_arr[1];
    $cat_icon[$cat_arr[0]]=$cat_arr[2];
    }
    //############################################################################## ######################################
    // Define Users
    //############################################################################## ######################################
    $all_users = file("$cutepath/data/users.db.php");
    foreach($all_users as $user)
    {
    if(!eregi("<\?",$member_db_line)){
    $user_arr = explode("|",$user);
    if($user_arr[4] != "")
    {
    if($user_arr[7] != 1 and $user_arr[5] != ""){ $my_names[$user_arr[2]] = "<a href=\"mailto:$user_arr[5]\">$user_arr[4]</a>"; }
    else{ $my_names[$user_arr[2]] = "$user_arr[4]"; }
    $name_to_nick[$user_arr[2]] = $user_arr[4];
    }
    else
    {
    if($user_arr[7] != 1 and $user_arr[5] != ""){ $my_names[$user_arr[2]] = "<a href=\"mailto:$user_arr[5]\">$user_arr[2]</a>"; }
    else{ $my_names[$user_arr[2]] = "$user_arr[2]"; }
    $name_to_nick[$user_arr[2]] = $user_arr[2];
    }

    if($user_arr[7] != 1){ $my_mails[$user_arr[2]] = $user_arr[5]; }
    else{ $my_mails[$user_arr[2]] = ""; }
    $my_passwords[$user_arr[2]] = $user_arr[3];
    $my_users[] = $user_arr[2];
    }
    }
    //############################################################################## ######################################
    // Add Comment
    //############################################################################## ######################################
    $allow_add_comment = run_filters('news-allow-comment',$allow_add_comment);
    if($allow_add_comment){
    $name = trim($name);

    echo '<script type="text/javascript">

    function setCookie(name, value, expires, path, domain, secure) {
    var curCookie = name + "=" + escape(value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
    document.cookie = curCookie;
    }

    function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
    } else
    begin += 2;
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    end = dc.length;
    return unescape(dc.substring(begin + prefix.length, end));
    }

    function deleteCookie(name, path, domain) {
    if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
    }

    </script>';

    if(isset($HTTP_X_FORWARDED_FOR)){ $ip = $HTTP_X_FORWARDED_FOR; }
    elseif(isset($HTTP_CLIENT_IP)) { $ip = $HTTP_CLIENT_IP; }
    if($ip == "") { $ip = $REMOTE_ADDR; }
    if($ip == "") { $ip = "not detected";}


    // Check Flood Protection
    if($config_flood_time != 0 and $config_flood_time != "" ){
    if(flooder($ip, $id) == TRUE ){
    echo("<div style=\"text-align: center;\">$lang_floodprot</div>");
    $CN_HALT = TRUE;
    break 1;
    }
    }
    // Check if IP is banned

    $blockip = FALSE;
    $old_ips = file("$cutepath/data/ipban.db.php");
    $new_ips = fopen("$cutepath/data/ipban.db.php", "w");
    @flock ($new_ips,2);
    foreach($old_ips as $old_ip_line){
    $ip_arr = explode("|", $old_ip_line);
    // AJ-FORK allow blocking of incomplete IPs
    if(!stristr($ip, $ip_arr[0])){
    // Oldstatement
    // $ip_arr[0] != $ip //
    fwrite($new_ips, $old_ip_line);
    }else{
    $countblocks = $ip_arr[1] = $ip_arr[1] + 1;
    fwrite($new_ips, "$ip_arr[0]|$countblocks||\n"); $blockip = TRUE;
    }
    }
    @flock ($new_ips,3);
    fclose($new_ips);
    if($blockip){
    echo("<div style=\"text-align: center;\">$lang_blocked</div>");
    $CN_HALT = TRUE;
    break 1;
    }

    // Check if name is Protected
    $is_member = FALSE;
    foreach($all_users as $member_db_line)
    {
    if(!eregi("<\?",$member_db_line) and $member_db_line != ""){
    $user_arr = explode("|",$member_db_line);

    //if the name is protected
    if((strtolower($user_arr[2]) == strtolower($name) or strtolower($user_arr[4]) == strtolower($name)) and $user_arr[3] != md5(md5($password)) and $name != "")
    {
    $comments = preg_replace(array("'\"'", "'\''", "''"), array("&quot;", "'", ""), $comments);
    $name = replace_comment("add", preg_replace("/\n/", "",$name));
    $mail = replace_comment("add", preg_replace("/\n/", "",$mail));

    echo"<div style=\"text-align: center;\">$lang_commentregistered<br />
    <form method=\"post\" action=\"\">
    <input type=\"password\" name=\"password\" />
    <input type=\"hidden\" name=\"name\" value=\"$name\" />
    <input type=\"hidden\" name=\"comments\" value=\"$comments\" />
    <input type=\"hidden\" name=\"mail\" value=\"$mail\" />
    <input type=\"hidden\" name=\"ip\" value=\"$ip\" />
    <input type=\"hidden\" name=\"subaction\" value=\"addcomment\" />
    <input type=\"hidden\" name=\"javasubaction\" value=\"$javasubaction\" />
    <input type=\"hidden\" name=\"show\" value=\"$show\" />
    <input type=\"hidden\" name=\"ucat\" value=\"$ucat\" />
    <input type=\"hidden\" name=\"rememberme\" value=\"$rememberme\" />
    $user_post_query
    <input type=\"submit\" value=\"$lang_commentregisteredbutton\"/></form></div>";
    $CN_HALT = TRUE;
    break 2;
    // exit();
    }

    if(strtolower($user_arr[2]) == strtolower($name)) $is_member = TRUE;
    }
    }

    // Check if only members can post comments
    if($config_only_registered_comment == "yes" and !$is_member){
    echo"<div style=\"text-align: center;\">$lang_onlyregistered</div>";
    $CN_HALT = TRUE;
    break 1;
    }

    //* Wrap long words
    if($config_auto_wrap > 1){
    $comments_arr = explode("\n", $comments);
    foreach($comments_arr as $line){
    $wraped_comm .= ereg_replace("([^ \/\/]{".$config_auto_wrap."})","\\1\n", $line) ."\n";
    }
    if(strlen($name) > $config_auto_wrap){ $name = substr($name, 0, $config_auto_wrap)." ..."; }
    $comments = $wraped_comm;
    }
    //*/

    $comments = replace_comment("add", run_filters('news-posted-comment-content',$comments));
    $name = replace_comment("add", preg_replace("/\n/", "",$name));
    $mail = replace_comment("add", preg_replace("/\n/", "",$mail));

    if($name == " " or $name == ""){
    echo("<div style=\"text-align: center;\">$lang_comment_needname</div>");
    $CN_HALT = TRUE;
    break 1;
    }
    if($mail == " " or $mail == ""){ $mail = "none"; }
    else{ $ok = FALSE;
    if(preg_match("/^[\.A-z0-9_\-]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $mail)) $ok = TRUE;
    elseif($config_allow_url_instead_mail == "yes" and preg_match("/((http(s?):\/\/)|(www\.))([\w\.]+)([\/\w+\.-?]+)/", $mail)) $ok = TRUE;
    elseif($config_allow_url_instead_mail != "yes"){
    echo("<div style=\"text-align: center;\">$lang_comment_invalidmail</div>");
    $CN_HALT = TRUE;
    break 1;
    }
    else{
    echo("<div style=\"text-align: center;\">$lang_comment_needvalidmail</div>");
    $CN_HALT = TRUE;
    break 1;
    }
    }

    if($comments == ""){
    echo("<div style=\"text-align: center;\">$lang_comment_notblank</div>");
    $CN_HALT = TRUE;
    break 1;
    }

    $time = time()+($config_date_adjust*60);

    // Add the Comment
    $old_comments = file("$comm_file");
    $new_comments = fopen("$comm_file", "w");
    @flock ($new_comments,2);
    $found = FALSE;
    foreach($old_comments as $old_comments_line)
    {
    $old_comments_arr = explode("|>|", $old_comments_line);
    if($old_comments_arr[0] == $id)
    {
    $old_comments_arr[1] = trim($old_comments_arr[1]);
    fwrite($new_comments, "$old_comments_arr[0]|>|$old_comments_arr[1]$time|$name|$mail|$ip|$comments||\n");
    $found = TRUE;
    }else{
    fwrite($new_comments, $old_comments_line);
    }
    }
    if(!$found){ fwrite($new_comments, "$id|>|$time|$name|$mail|$ip|$comments||\n"); }
    @flock ($new_comments,3);
    fclose($new_comments);

    // Add Flood Protection
    if($config_flood_time != "0" and $config_flood_time != "" ){

    $flood_file = fopen("$cutepath/data/flood.db.php", "a");
    @flock ($flood_file,2);
    fwrite($flood_file, time()."|$ip|$id|\n");
    @flock ($flood_file,3);
    fclose($flood_file);
    }
    // Sort problems with browser refresh posting comments twice + remembermefeature

    if ($rememberme == "yes") {
    echo "
    <script type=\"text/javascript\">
    var now = new Date();
    now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
    setCookie(\"commentname\", \"$name\", now);
    setCookie(\"commentmail\", \"$mail\", now);
    </script>";
    }
    else {
    echo "
    <script type=\"text/javascript\">
    var now = new Date();
    now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
    deleteCookie(\"commentname\");
    deleteCookie(\"commentmail\");
    </script>";
    }


    echo "
    <!-- Javascript redirect -->
    <script type=\"text/javascript\">self.location.href='http://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}?subaction=$javasubaction&id=$id&archive=$archive&start_from=$start_from&ucat=$ucat&$user_query';</script>";
    }
    //############################################################################## ######################################
    // Show Full Story
    //############################################################################## ######################################
    if($allow_full_story){
    $all_active_news = file("$news_file");

    foreach($all_active_news as $active_news)
    {
    $news_arr = explode("|", $active_news);

    if($news_arr[0] == $id and (!$catid or $catid == $news_arr[6]))
    {
    run_actions('news-fullstory-page');

    $found = TRUE;
    if($news_arr[4] == "" and (!eregi("\{short-story\}", $template_full)) ){ $news_arr[4] = $news_arr[3]; }

    if($my_names[$news_arr[1]]){ $my_author = $my_names[$news_arr[1]]; }
    else{ $my_author = $news_arr[1]; }
    $output = $template_full;
    $output = run_filters('news-show-generic', $output);
    $output = str_replace("{title}", $news_arr[2], $output);
    $output = str_replace("{date}", date($config_timestamp_active, $news_arr[0]), $output);
    // Add DATE variable to full story template
    $output = str_replace("{date-local}", strftime($config_timestamp_local_active, $news_arr[0]), $output);
    // END Add DATE variable FS
    $output = str_replace("{author}", $my_author, $output);

    // TEIT highlight-HACK
    if($highlight) {
    $news_arr[3] = str_replace($highlight, "<em>$highlight</em>", $news_arr[3]);
    $news_arr[4] = str_replace($highlight, "<em>$highlight</em>", $news_arr[4]);
    }
    // end teit highlight-hack

    $output = str_replace("{short-story}", run_filters('news-entry-content',$news_arr[3]), $output);
    $output = str_replace("{full-story}", run_filters('news-entry-content',$news_arr[4]), $output);
    if($news_arr[5] != ""){$output = str_replace("{avatar}", "<img alt=\"\" src=\"$news_arr[5]\" style=\"border: none;\" />", $output); }
    else{ $output = str_replace("{avatar}", "", $output); }
    $output = str_replace("{avatar-url}", "$news_arr[5]", $output);

    // Music hack by rilmith 3 lines below.
    if ($news_arr[7] != "") {
    $output = str_replace("{music}", $news_arr[7], $output); }
    else { $output = str_replace("{music}", $config_music_empty, $output); }

    $output = str_replace("{comments-num}", countComments($news_arr[0], $archive), $output);
    $output = str_replace("{category}", $cat[$news_arr[6]], $output);
    $output = str_replace("{category-id}", $news_arr[6], $output);
    if($cat_icon[$news_arr[6]] != ""){ $output = str_replace("{category-icon}", "<img style=\"border: none;\" alt=\"".$cat[$news_arr[6]]." icon\" src=\"".$cat_icon[$news_arr[6]]."\" />", $output); }
    else{ $output = str_replace("{category-icon}", "", $output); }

    if($config_comments_popup == "yes"){
    $output = str_replace("[com-link]","<a href=\"#\" onclick=\"window.open('$config_http_script_dir/show_news.php?subaction=showcomments&amp;template=$template&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]', '_News', '$config_comments_popup_string');return false;\">", $output);
    }else{
    $output = str_replace("[com-link]","<a href=\"$PHP_SELF?subaction=showcomments&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]&amp;$user_query\">", $output);
    }
    $output = str_replace("[/com-link]","</a>", $output);
    $output = str_replace("{author-name}", $name_to_nick[$news_arr[1]], $output);

    if($my_mails[$news_arr[1]] != ""){
    $output = str_replace("[mail]","<a href=\"mailto:".$my_mails[$news_arr[1]]."\">", $output);
    $output = str_replace("[/mail]","</a>", $output);
    }else{
    $output = str_replace("[mail]","", $output);
    $output = str_replace("[/mail]","", $output);
    }
    $output = str_replace("{news-id}", $news_arr[0], $output);
    $output = str_replace("{archive-id}", $archive, $output);
    $output = str_replace("{php-self}", $PHP_SELF, $output);
    $output = str_replace("{cute-http-path}", $config_http_script_dir, $output);

    // XFields v2.1 - addblock
    $xfieldsaction = "templatereplace";
    $xfieldsinput = $output;
    $xfieldsid = $news_arr[0];
    include("xfields.mdu");
    $output = $xfieldsoutput;
    // XFields v2.1 - End addblock

    $output = run_filters('news-entry',$output);

    $output = replace_news("show", $output);

    echo $output;
    $allow_comments = run_filters('news-show-comments', $allow_comments);
    }
    }
    if(!$found){
    echo("<div style=\"text-align: center;\">$lang_article_notfound</div>");
    $CN_HALT = TRUE;
    break 1;
    }
    }
    //############################################################################## ######################################
    // Show Comments
    //############################################################################## ######################################
    if($allow_comments){
    $all_comments = file("$comm_file");

    foreach($all_comments as $comment_line)
    {

    $comment_line = trim($comment_line);
    $comment_line_arr = explode("|>|", $comment_line);
    if($id == $comment_line_arr[0])
    {
    $individual_comments = explode("||", $comment_line_arr[1]);
    // Comments Pagination
    if($config_reverse_comments == "yes"){
    $individual_comments = array_reverse($individual_comments);
    $cghost = 1;} else {$cghost = 0;}
    $total_comments = count($individual_comments)-1;
    // Comments Pagination

    // {comnum} (a bloody mess that doesn't make sense this early in the morning!)
    $i = 0;
    if ($config_reverse_comments == "yes") {
    $cjnumber = $total_comments;
    if ($cstart) { $cjnumber -= $cstart -2; }
    }
    else { $cjnumber = 1;
    if ($cstart) { $cjnumber += $cstart -1;}
    }

    foreach($individual_comments as $comment)
    {

    // Comments Pagination
    if ($config_comments_pagination == "Yes") {
    $comment_index++;

    !isset($cnum) and $cnum = $config_comments_pagination_number;
    $cstart < 1 and $cstart = 1+$cghost;

    if ($comment_index < $cstart) continue;
    if ($comment_index >= $cstart + $cnum) break;
    }
    // Comments Pagination


    $comment_arr = explode("|", $comment);
    if($comment_arr[0] != "") {

    // Admin hack part One: Checking if user is registered (appelsinjuice.org)
    $admin_posting = FALSE;
    foreach($all_users as $member_db_line) {
    if(!eregi("<\?",$member_db_line) and $member_db_line != ""){
    $user_arr = explode("|",$member_db_line);
    if(strtolower($user_arr[2]) == strtolower($comment_arr[1]) || strtolower($user_arr[4]) == strtolower($comment_arr[1])) {
    $admin_posting = TRUE;
    }
    }
    }
    // END Admin hack part One

    $comment_arr[4] = stripslashes(rtrim($comment_arr[4]));

    if($comment_arr[2] != "none"){
    if( preg_match("/^[\.A-z0-9_\-]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $comment_arr[2])){ $url_target = "";$mail_or_url = "mailto:"; }
    else{
    $url_target = "";
    $mail_or_url = "";
    if(substr($comment_arr[2],0,3) == "www"){ $mail_or_url = "http://"; }
    }

    $output = str_replace("{author}", "<a $url_target href=\"$mail_or_url".stripslashes($comment_arr[2])."\">".stripslashes($comment_arr[1])."</a>", $template_comment);
    }
    else{ $output = str_replace("{author}", $comment_arr[1], $template_comment); }
    $comment_arr[4] = run_filters('news-comment-content',$comment_arr[4]);
    $output = str_replace("{mail}", "$comment_arr[2]",$output);

    // Show commenters host hack - adding variable {host} (appelsinjuice.org)
    if (!!stristr($output, "{host}")) {
    if ($comment_arr[3] && $comment_arr[3] != "not detected") {
    $hostname = gethostbyaddr($comment_arr[3]);
    $hostname = "*." . substr($hostname, strpos($hostname, ".") + 1);
    $output = str_replace("{host}", $hostname, $output);
    }
    else {
    $output = str_replace("{host}", "no host", $output);
    }
    }
    // END Show commenters host

    $output = str_replace("{music}", "$comment_arr[7]",$output);

    // Admin hack part Two: Adding a template variable (appelsinjuice.org)
    if ($admin_posting == "TRUE") {
    $output = str_replace("{admin}", $config_admin_template,$output); }
    else { $output = str_replace("{admin}", "",$output); }
    // END Admin hack part Two

    $output = str_replace("{date}", date($config_timestamp_comment, $comment_arr[0]),$output);
    $output = str_replace("{date-local}", strftime($config_timestamp_local_comment, $comment_arr[0]), $output);
    $output = str_replace("{comment-id}", $comment_arr[0],$output);
    $comment_arr[4] = preg_replace("/\
    PHP Code:
    (.*)\[\/PHP\]/esiU", "php_string('$1')", $comment_arr[4]);
                        
    $output = str_replace("{comment}", "<a id=\"" ."C" .$comment_arr[0]."\"></a>$comment_arr[4]",$output);
                        
    // {comnum} & altcolors
                        
    if($i%== 0) {
                            
    $com_alternating "cn_comment_odd";
                        }
                        else {
                            
    $com_alternating "cn_comment_even";
                        }
                        
    $output str_replace("{alternating}"$com_alternating$output);
                        
    $i++;

                        
    $output str_replace("{comnum}"$cjnumber$output);
                        if (
    $config_reverse_comments == "yes") {
                            
    $cjnumber--;
                        }
                        else { 
    $cjnumber++; }
                        
    $output run_filters('news-comment',$output);
                        
    $output replace_comment("show"$output);
                        echo 
    $output;

                    }
                }
            }
        }

            
    // Comments Pagination
            
    if ($config_comments_pagination == "Yes") {
                
    $cprev_next_msg $template_cprev_next;
                
    $nextcstart $cstart $cnum;
                
    $prevcstart $cstart $cnum;
                
    $COM_REQUEST_URI $PHP_SELF "?" cute_query_string($QUERY_STRING, array("cstart"));

                
    // <--- Previous
                
    if($cstart>1+$cghost){
                    
    $cprev_next_msg preg_replace("'\[prev-link\](.*?)\[/prev-link\]'si""<a href=\"{$COM_REQUEST_URI}&amp;cstart={$prevcstart}\">\\1</a>"$cprev_next_msg);
                }
                else {
                    
    $cprev_next_msg preg_replace("'\[prev-link\](.*?)\[/prev-link\]'si""\\1"$cprev_next_msg); $no_cprev TRUE;
                }
                
    // |<-- Previous

                // {pages}
                
    $cnumadd 0;
                
    $cpages "";
                for(
    $k=1;$cnumadd<$total_comments;$k++){
                    
    $cstartnum $cnum*($k-1)+1+$cghost;
                    if(
    $cstartnum != $cstart) {
                        
    $cpages .= "<a href=\"{$COM_REQUEST_URI}&amp;cstart={$cstartnum}\">$k</a> ";
                    }
                    else {
                        
    $cpages .= " <strong>| $k |</strong> ";
                    }
                
    $cnumadd $cnum*$k;
                }
                
    $cprev_next_msg str_replace("{pages}"$cpages$cprev_next_msg);
                
    // {pages} |

                // Next -->
                
    if($cstart+$cnum-1-$cghost $total_comments) {
                    
    $cprev_next_msg preg_replace("'\[next-link\](.*?)\[/next-link\]'si""<a href=\"{$COM_REQUEST_URI}&amp;cstart={$nextcstart}\">\\1</a>"$cprev_next_msg);
                }
                else {
                    
    $cprev_next_msg preg_replace("'\[next-link\](.*?)\[/next-link\]'si""\\1"$cprev_next_msg); $no_cnext TRUE;
                }
                
    // Next -->|

                
    if (!$no_cprev or !$no_cnext){ echo $cprev_next_msg; }
            }
            
    // Comments Pagination

        
    $template_form str_replace("{config_http_script_dir}""$config_http_script_dir"$template_form);

        
    $smilies_form "\n<script type=\"text/javascript\">
        //<![CDATA[
        function insertext(text, spot){
        document.forms['comment'].elements['comments'].value += ' ' +text;
        }
        //]]></script>
        "
    .insertSmilies('short'FALSE);

        
    $template_form str_replace("{smilies}"$smilies_form$template_form);
        if (
    $_COOKIE['commentname']) { $template_form str_replace("{savedname}"$_COOKIE['commentname'], $template_form); } else { $template_form str_replace("{savedname}"""$template_form); }
        if (
    $_COOKIE['commentmail']) { $template_form str_replace("{savedmail}"$_COOKIE['commentmail'], $template_form); } else { $template_form str_replace("{savedmail}"""$template_form); }
        
    // rememberme input
        
    $template_form str_replace("{remember}","<input type=\"checkbox\" id=\"rememberme\" name=\"rememberme\" value=\"yes\" checked=\"checked\" />"$template_form);

        echo
    "<form method=\"post\" id=\"comment\" action=\"\">".$template_form."<div><input type=\"hidden\" name=\"javasubaction\" value=\"$subaction\" /><input type=\"hidden\" name=\"subaction\" value=\"addcomment\" /><input type=\"hidden\" name=\"ucat\" value=\"$ucat\" /><input type=\"hidden\" name=\"show\" value=\"$show\" />$user_post_query</div></form>";

    }





    if( 
    substr($my_q, -5) == "&amp;" ){ $my_q substr($my_q0, -5); }

    return 
    $my_q;
    }


    //##############################################################################  ######################################
    //         Active News
    //##############################################################################  ######################################
    if($allow_active_news){

        
    $all_news file("$news_file");

            
    // stupid hack for sorting dates
            // if ($config_sortbydate == "yes") {
            
    asort($all_news);
            
    reset($all_news);
            
    $all_news array_reverse($all_news);
            
    // }

        
    if($reverse == TRUE){ $all_news array_reverse($all_news); }
        
    $all_news run_filters('news-recordset',$all_news);
        
    $count_all 0;
        if(isset(
    $category) and $category != ""){
            foreach(
    $all_news as $news_line){
                
    $news_arr explode("|"$news_line);
                if(
    $requested_cats and $requested_cats[$news_arr[6]] == TRUE){ $count_all ++; }
                else{ continue; }
            }
        }else{ 
    $count_all count($all_news); }
        
    // Sort News v1.0 - End addblock
        
    if (!empty($sortby)) {
        if (!
    function_exists('sortcmp')) {
         function 
    sortcmp($a$b) {
          global 
    $all_news$sortby;

          
    $news_a explode('|'$all_news[$a]);
          
    $news_b explode('|'$all_news[$b]);

          return 
    strnatcasecmp($news_a[$sortby], $news_b[$sortby]);
         }
        }
        
    uksort($all_news'sortcmp');
        unset(
    $sortby);
        }
        
    // Sort News v1.0 - End addblock
        
    $i 0;
        
    $o 0;
        
    $showed 0;
        
    $repeat TRUE;
        
    $url_archive $archive;

        while(
    $repeat != FALSE){

            foreach(
    $all_news as $news_line){

               
    $news_arr explode("|"$news_line);
               
    /*
            // prospective posting
            $nowtime = time() + ($config_date_adjust * 60);
            if (($config_prospective == "On" and $nowtime <= $news_arr[0])) {
            $count_all--;
            continue;
            }*/
            
    $modifier run_filters('news-loop''');

            if (
    $modifier == "skip") {
                
    $count_all--;
                continue;
                }

            if(
    $category and $requested_cats[$news_arr[6]] != TRUE){ continue; }

            if(isset(
    $start_from) and $start_from != ""){
                if(
    $i $start_from){
                    
    $i++;
                    continue; }
                elseif(
    $showed == $number){  break; }
            }

            if(
    $my_names[$news_arr[1]]){ $my_author $my_names[$news_arr[1]]; }
            else{ 
    $my_author $news_arr[1]; }

            
    $output $template_active;
            
    // TEIT highlight-HACK
            
    if($highlight) {
                
    $news_arr[3] = str_replace($highlight"<em>$highlight</em>"$news_arr[3]);
                }
            
    // end teit highlight-hack
            // alternating
            
    if($o%== 0) { $nws_alternating "cn_news_odd"; } else { $nws_alternating "cn_news_even"; }
            
    $output str_replace("{alternating}"$nws_alternating$output);
            
    $o++;
            
    $output str_replace("{title}"$news_arr[2], $output);

            
    // Add DATE variable to active news template
            
    $output str_replace("{date}"date($config_timestamp_active$news_arr[0]), $output);
            
    $output str_replace("{date-local}"strftime($config_timestamp_local_active$news_arr[0]), $output);
            
    // END Add DATE variable to AN
            
    $output str_replace("{author}"$my_author$output);
            if(
    $news_arr[5] != ""){$output str_replace("{avatar}""<img alt=\"\" src=\"$news_arr[5]\" style=\"border: none;\" />"$output); }
            else{ 
    $output str_replace("{avatar}"""$output); }
            
    $output str_replace("{avatar-url}""$news_arr[5]"$output);

        
    // Music hack by rilmith 3 lines below.
        
    if ($news_arr[7] != "") {
        
    $output str_replace("{music}"$news_arr[7], $output); }
        else { 
    $output str_replace("{music}"$config_music_empty$output); }

            
    $output str_replace("[link]","<a title=\"$lang_article_linktext\" href=\"$PHP_SELF?subaction=showfull&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]&amp;$user_query\">"$output);
            
    $output str_replace("[/link]","</a>"$output);
            
    $output str_replace("{comments-num}"countComments($news_arr[0], $archive), $output);
            
    $output str_replace("{short-story}"run_filters('news-entry-content',$news_arr[3]), $output);
            
    $output str_replace("{full-story}"run_filters('news-entry-content',$news_arr[4]), $output);
            
    $output str_replace("{category}"$cat[$news_arr[6]], $output);
            
    $output str_replace("{category-id}"$news_arr[6], $output);
            if(
    $cat_icon[$news_arr[6]] != ""){ $output str_replace("{category-icon}""<img alt=\"".$cat[$news_arr[6]]." icon\" style=\"border: none;\" src=\"".$cat_icon[$news_arr[6]]."\" />"$output); }
            else{ 
    $output str_replace("{category-icon}"""$output); }

            
    $output str_replace("{author-name}"$name_to_nick[$news_arr[1]], $output);

             if(
    $my_mails[$news_arr[1]] != ""){
                 
    $output str_replace("[mail]","<a href=\"mailto:".$my_mails[$news_arr[1]]."\">"$output);
                 
    $output str_replace("[/mail]","</a>"$output);
            }else{
                 
    $output str_replace("[mail]",""$output);
                 
    $output str_replace("[/mail]",""$output);
             }
            
    // RSS
            
    $output str_replace("{rssmail}"$my_mails[$news_arr[1]], $output);
            
    $output str_replace("{rssdate}"date("r"$news_arr[0]), $output);
            
    $output str_replace("{rssauthor}"$news_arr[1], $output);
            
    // end rss
            
    $output str_replace("{news-id}"$news_arr[0], $output);
            
    $output str_replace("{archive-id}"$archive$output);
            
    $output str_replace("{php-self}"$PHP_SELF$output);
            
    $output str_replace("{cute-http-path}"$config_http_script_dir$output);

    // XFields v2.1 - addblock
    $xfieldsaction "templatereplace";
    $xfieldsinput $output;
    $xfieldsid $news_arr[0];
    include(
    "xfields.mdu");
    $output $xfieldsoutput;
    // XFields v2.1 - End addblock

            
    $output run_filters('news-entry',$output);
            
    $output replace_news("show"$output);


            if(
    $news_arr[4] != "" or $action == "showheadlines"){//if full story
                
    if($config_full_popup == "yes"){

                    
    $output preg_replace("/\\[full-link\\]/","<a href=\"#\" onclick=\"window.open('$config_http_script_dir/show_news.php?subaction=showfull&amp;id=$news_arr[0]&amp;archive=$archive&amp;template=$template', '_News', '$config_full_popup_string');return false;\">"$output);
                }else{
                    
    $output str_replace("[full-link]","<a href=\"$PHP_SELF?subaction=showfull&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]&amp;$user_query\">"$output);
                }
                    
    $output str_replace("[/full-link]","</a>"$output);
            }else{
                
    $output preg_replace("'\\[full-link\\].*?\\[/full-link\\]'si","<!-- no full story-->"$output);
            }

    //        $output = run_filters('news-active-comlink', $output);
            
    if($config_comments_popup == "yes"){
                
    $output str_replace("[com-link]","<a href=\"#\" onclick=\"window.open('$config_http_script_dir/show_news.php?subaction=showcomments&amp;template=$template&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]', '_News', '$config_comments_popup_string');return false;\">"$output);
            }else{
                
    $output str_replace("[com-link]","<a href=\"$PHP_SELF?subaction=showcomments&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]&amp;$user_query\">"$output);
            }

            
    $output str_replace("[/com-link]","</a>"$output);

    // AJB Date header option (based on code by SMKILLER2, rescued by The Dude)
    if ($config_date_header == "Yes") {
        if (
    $dateheader_S != date("dmY"$news_arr[0])) {
            
    // 161-hacks above and below
            
    $dateheader_S date("dmY"$news_arr[0]);

            
    $dateheader date($config_date_headerformat$news_arr[0]);
            
    $dateheader_local strftime($config_date_headerformatlocal$news_arr[0]);
            
    $dateheader_p $template_dateheader;
            
    $dateheader_p str_replace("{dateheader}"$dateheader$dateheader_p);
            
    $dateheader_p str_replace("{dateheader-local}"strftime($dateheader_local$news_arr[0]), $dateheader_p);

             echo 
    $dateheader_p;
            }
        }
    // End AJB Date header option



            
    echo $output;
            
    $showed++;
            
    $i++;

            if(
    $number != and $number == $i){ break; }
            }
            
    $used_archives[$archive] = TRUE;
    // Archives Looop
            
    if($i $number and $only_active != TRUE){

                if(!
    $handle opendir("$cutepath/data/archives")){ die("<div style=\"text-align: center;\">$lang_archive_notopen</div>"); }
                     while (
    false !== ($file readdir($handle)))
                     {
                         if(
    $file != "." and $file != ".." and eregi("news.arch"$file))
                         {
                             
    $file_arr explode(".",$file);
                            
    $archives_arr[$file_arr[0]] = $file_arr[0];
                         }
                     }
                
    closedir($handle);

                
    $archives_arr[$in_use]="";
                
    $in_use max($archives_arr);

                if(
    $in_use != "" and !$used_archives[$in_use]){
                    
    $all_news file("$cutepath/data/archives/$in_use.news.arch");
                    
    $archive $in_use;
                    
    $used_archives[$in_use] = TRUE;
                }else{ 
    $repeat FALSE; }

            }else{ 
    $repeat FALSE; }
        }

    // << Previous   &   Next >>

        
    $prev_next_msg $template_prev_next;

        
    //----------------------------------
        // Previous link
        //----------------------------------
        
    if(isset($start_from) and $start_from != "" and $start_from 0){
            
    $prev $start_from $number;
            
    $prev_next_msg preg_replace("'\[prev-link\](.*?)\[/prev-link\]'si""<a href=\"$PHP_SELF?start_from=$prev&amp;archive=$url_archive&amp;subaction=$subaction&amp;id=$id&amp;$u  ser_query\">\\1</a>"$prev_next_msg);
        }else{ 
    $prev_next_msg preg_replace("'\[prev-link\](.*?)\[/prev-link\]'si""\\1"$prev_next_msg); $no_prev TRUE; }

        
    //----------------------------------
        // Pages
        //----------------------------------
        
    if($number){
        
    $pages_count = @ceil($count_all/$number);
        
    $pages_start_from 0;
        
    $pages "";
        for(
    $j=1;$j<=$pages_count;$j++){
            if(
    $pages_start_from != $start_from){ $pages .= "<a href=\"$PHP_SELF?start_from=$pages_start_from&amp;archive=$url_archive&amp;subaction=$subacti  on&amp;id=$id&amp;$user_query\">$j</a> "; }
            else{ 
    $pages .= " <strong>| $j |</strong> "; }
            
    $pages_start_from += $number;
        }
        
    $prev_next_msg str_replace("{pages}"$pages$prev_next_msg);
        }
        
    //----------------------------------
        // Next link
        //----------------------------------
        
    if($number $count_all and $i $count_all){
            
    $prev_next_msg preg_replace("'\[next-link\](.*?)\[/next-link\]'si""<a href=\"$PHP_SELF?start_from=$i&amp;archive=$url_archive&amp;subaction=$subaction&amp;id=$id&amp;$user  _query\">\\1</a>"$prev_next_msg);
        }else{ 
    $prev_next_msg preg_replace("'\[next-link\](.*?)\[/next-link\]'si""\\1"$prev_next_msg); $no_next TRUE;}


        if    (!
    $no_prev or !$no_next){ echo $prev_next_msg; }
    }
    }while(
    0);
    ?> 

  20. #20
    SitePoint Enthusiast Anders N's Avatar
    Join Date
    Dec 2004
    Location
    Norway
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Fatal error: Call to undefined function: replace_news() in /usr/home/web/wno32422/ringetoner/inc/shows.inc.php on line 796

    Thanks for all the help btw. I really appreciate it!

  21. #21
    Free Geek computerages's Avatar
    Join Date
    Oct 2004
    Location
    /dev/null
    Posts
    1,071
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Anders N
    Fatal error: Call to undefined function: replace_news() in /usr/home/web/wno32422/ringetoner/inc/shows.inc.php on line 796

    Thanks for all the help btw. I really appreciate it!
    No problem, I am here to help out the peopel.

    [php]<?PHP

    if (!defined('PLUGIN_FRAMEWORK_VERSION')) {
    include($cutepath.'/inc/plugins.php');
    LoadActivePlugins();
    }

    do{ // Used if we want to display some error to the user and halt the rest of the script



    ////////////////////////////////////////////////////////
    // Function: replace_news
    // Description: Replaces news charactars

    function replace_news($way, $sourse, $replce_n_to_br=TRUE, $use_html=TRUE){
    global $config_allow_html_in_news, $config_allow_html_in_comments, $config_http_script_dir, $config_smilies;
    $sourse = stripslashes($sourse);

    if($way == "show")
    {
    $find= array(

    /* 1 */ "'\[upimage=([^\]]*?) ([^\]]*?)\]'i",
    /* 2 */ "'\[upimage=(.*?)\]'i",
    /* 3 */ "'\[b\](.*?)\[/b\]'i",
    /* 4 */ "'\[i\](.*?)\[/i\]'i",
    /* 5 */ "'\[u\](.*?)\[/u\]'i",
    /* 6 */ "'\[link\](.*?)\[/link\]'i",
    /* 7 */ "'\[color=(.*?)\](.*?)\[/color\]'i",
    /* 8 */ "'\[size=(.*?)\](.*?)\[/size\]'i",
    /* 9 */ "'\[font=(.*?)\](.*?)\[/font\]'i",
    /* 10 */ "'\[align=(.*?)\](.*?)\[/align\]'i",
    /* 12 */ "'\[image=(.*?)\]'i",
    /* 13 */ "'\[link=(.*?)\](.*?)\[/link\]'i",

    /* 14 */ "'\[quote=(.*?)\](.*?)\[/quote\]'i",
    /* 15 */ "'\[quote\](.*?)\[/quote\]'i",

    /* 16 */ "'\[list\]'i",
    /* 17 */ "'\[/list\]'i",
    /* 18 */ "'\[\*\]'i",
    "'{nl}'",
    );

    $replace=array(

    /* 1 */ "<img \\2 src=\"${config_http_script_dir}/skins/images/upskins/images/\\1\" style=\"border: none;\" alt=\"\" />",
    /* 2 */ "<img src=\"${config_http_script_dir}/skins/images/upskins/images/\\1\" style=\"border: none;\" alt=\"\" />",
    /* 3 */ "<strong>\\1</strong>",
    /* 4 */ "<em>\\1</em>",
    /* 5 */ "<span style=\"text-decoration: underline;\">\\1</span>",
    /* 6 */ "<a href=\"\\1\">\\1</a>",
    /* 7 */ "<span style=\"color: \\1;\">\\2</span>",
    /* 8 */ "<span style=\"font-size: \\1pt;\">\\2</span>",
    /* 9 */ "<span style=\"font-family: \\1;\">\\2</span>",
    /* 10 */ "<div style=\"text-align: \\1;\">\\2</div>",
    /* 12 */ "<img src=\"\\1\" style=\"border: none;\" alt=\"\" />",
    /* 13 */ "<a href=\"\\1\">\\2</a>",

    /* 14 */ "<blockquote><p><strong>\\1/strong><br />\\2</p></blockquote>",
    /* 15 */ "<blockquote><p>\\1</p></blockquote>",

    /* 16 */ "<ul>",
    /* 17 */ "</ul>",
    /* 18 */ "<li>",
    "\n",
    );

    $smilies_arr = explode(",", $config_smilies);
    foreach($smilies_arr as $smile){
    $smile = trim($smile);
    $find[] = "':$smile:'";
    $replace[] = "<img style=\"border: none;\" alt=\"$smile\" src=\"$config_http_script_dir/data/emoticons/$smile.gif\" />";
    }
    }
    elseif($way == "add"){

    $find = array(
    "'\|'",
    "'\r'",
    );
    $replace = array(
    "|",
    "",
    );
    /* // Replaced by Format Switcher plugin
    if($use_html != TRUE){
    $find[] = "'<'";
    $find[] = "'>'";

    $replace[] = "&lt;";
    $replace[] = "&gt;";
    }
    if($replce_n_to_br == TRUE){
    $find[] = "'\n'";
    $replace[] = "<br />";
    }else{ */
    $find[] = "'\n'";
    $replace[] = "{nl}";
    // }

    }
    elseif($way == "admin"){

    $find = array(
    "''",
    "'<br />'",
    "'{nl}'",
    );
    $replace = array(
    "",
    "\n",
    "\n",
    );

    }

    $sourse = preg_replace($find,$replace,$sourse);
    return $sourse;
    }



    ////////////////////////////////////////////////////////
    // Function: CountComments
    // Description: Count how many comments belong to a specific article

    function CountComments($id, $archive = FALSE){

    global $cutepath;

    if($cutepath == ""){ $cutepath = "."; }
    $result = "0";
    if($archive){ $all_comments = file("$cutepath/data/archives/${archive}.comments.arch"); }
    else{ $all_comments = file("$cutepath/data/comments.txt"); }

    foreach($all_comments as $comment_line)
    {
    $comment_arr_1 = explode("|>|", $comment_line);
    if($comment_arr_1[0] == $id)
    {
    $comment_arr_2 = explode("||", $comment_arr_1[1]);
    $result = count($comment_arr_2)-1;

    }
    }

    return $result;
    }




    ///////////////////////////////////////////////////////
    // Function: cute_query_string
    // Description: Format the Query_String for CuteNews purpuses index.php?

    function cute_query_string($q_string, $strips, $type="get"){
    foreach($strips as $key){
    $strips[$key] = TRUE;
    }
    $var_value = explode("&", $q_string);

    foreach($var_value as $var_peace){
    $parts = explode("=", $var_peace);
    if($strips[$parts[0]] != TRUE and $parts[0] != ""){
    if($type == "post"){
    $my_q .= "<input type=\"hidden\" name=\"".$parts[0]."\" value=\"".$parts[1]."\" />\n";
    }else{
    $my_q .= "$var_peace&amp;";
    }
    }
    }








    // [locales] v[1] - addblock
    setlocale (LC_ALL, $config_locale_active);
    // [locales] v[1] - End addblock

    // AJB Visible language addon
    $vis_lang_file = $cutepath . "/inc/lang/" . $config_cn_lang . ".visible.php";
    if (file_exists($vis_lang_file)) {
    include($vis_lang_file);
    }
    // END AJBVISLANGADD

    $user_query = cute_query_string($QUERY_STRING, array("start_from", "archive", "subaction", "id", "ucat"));
    $user_post_query = cute_query_string($QUERY_STRING, array("start_from", "archive", "subaction", "id", "ucat"), "post");

    // [locales] v[1] - addblock
    //############################################################################## ######################################
    // Some localized date setup / Not working ATM
    //############################################################################## ######################################

    if ($config_date_select && $config_date_select != "Other") {
    $config_timestamp_active = $config_date_select;
    }
    // [locales] v[1] - End addblock
    //############################################################################## ######################################
    // Define Categories
    //############################################################################## ######################################
    $cat_lines = file("$cutepath/data/category.db.php");
    foreach($cat_lines as $single_line){
    $cat_arr = explode("|", $single_line);
    $cat[$cat_arr[0]] = $cat_arr[1];
    $cat_icon[$cat_arr[0]]=$cat_arr[2];
    }
    //############################################################################## ######################################
    // Define Users
    //############################################################################## ######################################
    $all_users = file("$cutepath/data/users.db.php");
    foreach($all_users as $user)
    {
    if(!eregi("<\?",$member_db_line)){
    $user_arr = explode("|",$user);
    if($user_arr[4] != "")
    {
    if($user_arr[7] != 1 and $user_arr[5] != ""){ $my_names[$user_arr[2]] = "<a href=\"mailto:$user_arr[5]\">$user_arr[4]</a>"; }
    else{ $my_names[$user_arr[2]] = "$user_arr[4]"; }
    $name_to_nick[$user_arr[2]] = $user_arr[4];
    }
    else
    {
    if($user_arr[7] != 1 and $user_arr[5] != ""){ $my_names[$user_arr[2]] = "<a href=\"mailto:$user_arr[5]\">$user_arr[2]</a>"; }
    else{ $my_names[$user_arr[2]] = "$user_arr[2]"; }
    $name_to_nick[$user_arr[2]] = $user_arr[2];
    }

    if($user_arr[7] != 1){ $my_mails[$user_arr[2]] = $user_arr[5]; }
    else{ $my_mails[$user_arr[2]] = ""; }
    $my_passwords[$user_arr[2]] = $user_arr[3];
    $my_users[] = $user_arr[2];
    }
    }
    //############################################################################## ######################################
    // Add Comment
    //############################################################################## ######################################
    $allow_add_comment = run_filters('news-allow-comment',$allow_add_comment);
    if($allow_add_comment){
    $name = trim($name);

    echo '<script type="text/javascript">

    function setCookie(name, value, expires, path, domain, secure) {
    var curCookie = name + "=" + escape(value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
    document.cookie = curCookie;
    }

    function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
    } else
    begin += 2;
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    end = dc.length;
    return unescape(dc.substring(begin + prefix.length, end));
    }

    function deleteCookie(name, path, domain) {
    if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
    }

    </script>';

    if(isset($HTTP_X_FORWARDED_FOR)){ $ip = $HTTP_X_FORWARDED_FOR; }
    elseif(isset($HTTP_CLIENT_IP)) { $ip = $HTTP_CLIENT_IP; }
    if($ip == "") { $ip = $REMOTE_ADDR; }
    if($ip == "") { $ip = "not detected";}


    // Check Flood Protection
    if($config_flood_time != 0 and $config_flood_time != "" ){
    if(flooder($ip, $id) == TRUE ){
    echo("<div style=\"text-align: center;\">$lang_floodprot</div>");
    $CN_HALT = TRUE;
    break 1;
    }
    }
    // Check if IP is banned

    $blockip = FALSE;
    $old_ips = file("$cutepath/data/ipban.db.php");
    $new_ips = fopen("$cutepath/data/ipban.db.php", "w");
    @flock ($new_ips,2);
    foreach($old_ips as $old_ip_line){
    $ip_arr = explode("|", $old_ip_line);
    // AJ-FORK allow blocking of incomplete IPs
    if(!stristr($ip, $ip_arr[0])){
    // Oldstatement
    // $ip_arr[0] != $ip //
    fwrite($new_ips, $old_ip_line);
    }else{
    $countblocks = $ip_arr[1] = $ip_arr[1] + 1;
    fwrite($new_ips, "$ip_arr[0]|$countblocks||\n"); $blockip = TRUE;
    }
    }
    @flock ($new_ips,3);
    fclose($new_ips);
    if($blockip){
    echo("<div style=\"text-align: center;\">$lang_blocked</div>");
    $CN_HALT = TRUE;
    break 1;
    }

    // Check if name is Protected
    $is_member = FALSE;
    foreach($all_users as $member_db_line)
    {
    if(!eregi("<\?",$member_db_line) and $member_db_line != ""){
    $user_arr = explode("|",$member_db_line);

    //if the name is protected
    if((strtolower($user_arr[2]) == strtolower($name) or strtolower($user_arr[4]) == strtolower($name)) and $user_arr[3] != md5(md5($password)) and $name != "")
    {
    $comments = preg_replace(array("'\"'", "'\''", "''"), array("&quot;", "'", ""), $comments);
    $name = replace_comment("add", preg_replace("/\n/", "",$name));
    $mail = replace_comment("add", preg_replace("/\n/", "",$mail));

    echo"<div style=\"text-align: center;\">$lang_commentregistered<br />
    <form method=\"post\" action=\"\">
    <input type=\"password\" name=\"password\" />
    <input type=\"hidden\" name=\"name\" value=\"$name\" />
    <input type=\"hidden\" name=\"comments\" value=\"$comments\" />
    <input type=\"hidden\" name=\"mail\" value=\"$mail\" />
    <input type=\"hidden\" name=\"ip\" value=\"$ip\" />
    <input type=\"hidden\" name=\"subaction\" value=\"addcomment\" />
    <input type=\"hidden\" name=\"javasubaction\" value=\"$javasubaction\" />
    <input type=\"hidden\" name=\"show\" value=\"$show\" />
    <input type=\"hidden\" name=\"ucat\" value=\"$ucat\" />
    <input type=\"hidden\" name=\"rememberme\" value=\"$rememberme\" />
    $user_post_query
    <input type=\"submit\" value=\"$lang_commentregisteredbutton\"/></form></div>";
    $CN_HALT = TRUE;
    break 2;
    // exit();
    }

    if(strtolower($user_arr[2]) == strtolower($name)) $is_member = TRUE;
    }
    }

    // Check if only members can post comments
    if($config_only_registered_comment == "yes" and !$is_member){
    echo"<div style=\"text-align: center;\">$lang_onlyregistered</div>";
    $CN_HALT = TRUE;
    break 1;
    }

    //* Wrap long words
    if($config_auto_wrap > 1){
    $comments_arr = explode("\n", $comments);
    foreach($comments_arr as $line){
    $wraped_comm .= ereg_replace("([^ \/\/]{".$config_auto_wrap."})","\\1\n", $line) ."\n";
    }
    if(strlen($name) > $config_auto_wrap){ $name = substr($name, 0, $config_auto_wrap)." ..."; }
    $comments = $wraped_comm;
    }
    //*/

    $comments = replace_comment("add", run_filters('news-posted-comment-content',$comments));
    $name = replace_comment("add", preg_replace("/\n/", "",$name));
    $mail = replace_comment("add", preg_replace("/\n/", "",$mail));

    if($name == " " or $name == ""){
    echo("<div style=\"text-align: center;\">$lang_comment_needname</div>");
    $CN_HALT = TRUE;
    break 1;
    }
    if($mail == " " or $mail == ""){ $mail = "none"; }
    else{ $ok = FALSE;
    if(preg_match("/^[\.A-z0-9_\-]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $mail)) $ok = TRUE;
    elseif($config_allow_url_instead_mail == "yes" and preg_match("/((http(s?):\/\/)|(www\.))([\w\.]+)([\/\w+\.-?]+)/", $mail)) $ok = TRUE;
    elseif($config_allow_url_instead_mail != "yes"){
    echo("<div style=\"text-align: center;\">$lang_comment_invalidmail</div>");
    $CN_HALT = TRUE;
    break 1;
    }
    else{
    echo("<div style=\"text-align: center;\">$lang_comment_needvalidmail</div>");
    $CN_HALT = TRUE;
    break 1;
    }
    }

    if($comments == ""){
    echo("<div style=\"text-align: center;\">$lang_comment_notblank</div>");
    $CN_HALT = TRUE;
    break 1;
    }

    $time = time()+($config_date_adjust*60);

    // Add the Comment
    $old_comments = file("$comm_file");
    $new_comments = fopen("$comm_file", "w");
    @flock ($new_comments,2);
    $found = FALSE;
    foreach($old_comments as $old_comments_line)
    {
    $old_comments_arr = explode("|>|", $old_comments_line);
    if($old_comments_arr[0] == $id)
    {
    $old_comments_arr[1] = trim($old_comments_arr[1]);
    fwrite($new_comments, "$old_comments_arr[0]|>|$old_comments_arr[1]$time|$name|$mail|$ip|$comments||\n");
    $found = TRUE;
    }else{
    fwrite($new_comments, $old_comments_line);
    }
    }
    if(!$found){ fwrite($new_comments, "$id|>|$time|$name|$mail|$ip|$comments||\n"); }
    @flock ($new_comments,3);
    fclose($new_comments);

    // Add Flood Protection
    if($config_flood_time != "0" and $config_flood_time != "" ){

    $flood_file = fopen("$cutepath/data/flood.db.php", "a");
    @flock ($flood_file,2);
    fwrite($flood_file, time()."|$ip|$id|\n");
    @flock ($flood_file,3);
    fclose($flood_file);
    }
    // Sort problems with browser refresh posting comments twice + remembermefeature

    if ($rememberme == "yes") {
    echo "
    <script type=\"text/javascript\">
    var now = new Date();
    now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
    setCookie(\"commentname\", \"$name\", now);
    setCookie(\"commentmail\", \"$mail\", now);
    </script>";
    }
    else {
    echo "
    <script type=\"text/javascript\">
    var now = new Date();
    now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
    deleteCookie(\"commentname\");
    deleteCookie(\"commentmail\");
    </script>";
    }


    echo "
    <!-- Javascript redirect -->
    <script type=\"text/javascript\">self.location.href='http://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}?subaction=$javasubaction&id=$id&archive=$archive&start_from=$start_from&ucat=$ucat&$user_query';</script>";
    }
    //############################################################################## ######################################
    // Show Full Story
    //############################################################################## ######################################
    if($allow_full_story){
    $all_active_news = file("$news_file");

    foreach($all_active_news as $active_news)
    {
    $news_arr = explode("|", $active_news);

    if($news_arr[0] == $id and (!$catid or $catid == $news_arr[6]))
    {
    run_actions('news-fullstory-page');

    $found = TRUE;
    if($news_arr[4] == "" and (!eregi("\{short-story\}", $template_full)) ){ $news_arr[4] = $news_arr[3]; }

    if($my_names[$news_arr[1]]){ $my_author = $my_names[$news_arr[1]]; }
    else{ $my_author = $news_arr[1]; }
    $output = $template_full;
    $output = run_filters('news-show-generic', $output);
    $output = str_replace("{title}", $news_arr[2], $output);
    $output = str_replace("{date}", date($config_timestamp_active, $news_arr[0]), $output);
    // Add DATE variable to full story template
    $output = str_replace("{date-local}", strftime($config_timestamp_local_active, $news_arr[0]), $output);
    // END Add DATE variable FS
    $output = str_replace("{author}", $my_author, $output);

    // TEIT highlight-HACK
    if($highlight) {
    $news_arr[3] = str_replace($highlight, "<em>$highlight</em>", $news_arr[3]);
    $news_arr[4] = str_replace($highlight, "<em>$highlight</em>", $news_arr[4]);
    }
    // end teit highlight-hack

    $output = str_replace("{short-story}", run_filters('news-entry-content',$news_arr[3]), $output);
    $output = str_replace("{full-story}", run_filters('news-entry-content',$news_arr[4]), $output);
    if($news_arr[5] != ""){$output = str_replace("{avatar}", "<img alt=\"\" src=\"$news_arr[5]\" style=\"border: none;\" />", $output); }
    else{ $output = str_replace("{avatar}", "", $output); }
    $output = str_replace("{avatar-url}", "$news_arr[5]", $output);

    // Music hack by rilmith 3 lines below.
    if ($news_arr[7] != "") {
    $output = str_replace("{music}", $news_arr[7], $output); }
    else { $output = str_replace("{music}", $config_music_empty, $output); }

    $output = str_replace("{comments-num}", countComments($news_arr[0], $archive), $output);
    $output = str_replace("{category}", $cat[$news_arr[6]], $output);
    $output = str_replace("{category-id}", $news_arr[6], $output);
    if($cat_icon[$news_arr[6]] != ""){ $output = str_replace("{category-icon}", "<img style=\"border: none;\" alt=\"".$cat[$news_arr[6]]." icon\" src=\"".$cat_icon[$news_arr[6]]."\" />", $output); }
    else{ $output = str_replace("{category-icon}", "", $output); }

    if($config_comments_popup == "yes"){
    $output = str_replace("[com-link]","<a href=\"#\" onclick=\"window.open('$config_http_script_dir/show_news.php?subaction=showcomments&amp;template=$template&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]', '_News', '$config_comments_popup_string');return false;\">", $output);
    }else{
    $output = str_replace("[com-link]","<a href=\"$PHP_SELF?subaction=showcomments&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]&amp;$user_query\">", $output);
    }
    $output = str_replace("[/com-link]","</a>", $output);
    $output = str_replace("{author-name}", $name_to_nick[$news_arr[1]], $output);

    if($my_mails[$news_arr[1]] != ""){
    $output = str_replace("[mail]","<a href=\"mailto:".$my_mails[$news_arr[1]]."\">", $output);
    $output = str_replace("[/mail]","</a>", $output);
    }else{
    $output = str_replace("[mail]","", $output);
    $output = str_replace("[/mail]","", $output);
    }
    $output = str_replace("{news-id}", $news_arr[0], $output);
    $output = str_replace("{archive-id}", $archive, $output);
    $output = str_replace("{php-self}", $PHP_SELF, $output);
    $output = str_replace("{cute-http-path}", $config_http_script_dir, $output);

    // XFields v2.1 - addblock
    $xfieldsaction = "templatereplace";
    $xfieldsinput = $output;
    $xfieldsid = $news_arr[0];
    include("xfields.mdu");
    $output = $xfieldsoutput;
    // XFields v2.1 - End addblock

    $output = run_filters('news-entry',$output);

    $output = replace_news("show", $output);

    echo $output;
    $allow_comments = run_filters('news-show-comments', $allow_comments);
    }
    }
    if(!$found){
    echo("<div style=\"text-align: center;\">$lang_article_notfound</div>");
    $CN_HALT = TRUE;
    break 1;
    }
    }
    //############################################################################## ######################################
    // Show Comments
    //############################################################################## ######################################
    if($allow_comments){
    $all_comments = file("$comm_file");

    foreach($all_comments as $comment_line)
    {

    $comment_line = trim($comment_line);
    $comment_line_arr = explode("|>|", $comment_line);
    if($id == $comment_line_arr[0])
    {
    $individual_comments = explode("||", $comment_line_arr[1]);
    // Comments Pagination
    if($config_reverse_comments == "yes"){
    $individual_comments = array_reverse($individual_comments);
    $cghost = 1;} else {$cghost = 0;}
    $total_comments = count($individual_comments)-1;
    // Comments Pagination

    // {comnum} (a bloody mess that doesn't make sense this early in the morning!)
    $i = 0;
    if ($config_reverse_comments == "yes") {
    $cjnumber = $total_comments;
    if ($cstart) { $cjnumber -= $cstart -2; }
    }
    else { $cjnumber = 1;
    if ($cstart) { $cjnumber += $cstart -1;}
    }

    foreach($individual_comments as $comment)
    {

    // Comments Pagination
    if ($config_comments_pagination == "Yes") {
    $comment_index++;

    !isset($cnum) and $cnum = $config_comments_pagination_number;
    $cstart < 1 and $cstart = 1+$cghost;

    if ($comment_index < $cstart) continue;
    if ($comment_index >= $cstart + $cnum) break;
    }
    // Comments Pagination


    $comment_arr = explode("|", $comment);
    if($comment_arr[0] != "") {

    // Admin hack part One: Checking if user is registered (appelsinjuice.org)
    $admin_posting = FALSE;
    foreach($all_users as $member_db_line) {
    if(!eregi("<\?",$member_db_line) and $member_db_line != ""){
    $user_arr = explode("|",$member_db_line);
    if(strtolower($user_arr[2]) == strtolower($comment_arr[1]) || strtolower($user_arr[4]) == strtolower($comment_arr[1])) {
    $admin_posting = TRUE;
    }
    }
    }
    // END Admin hack part One

    $comment_arr[4] = stripslashes(rtrim($comment_arr[4]));

    if($comment_arr[2] != "none"){
    if( preg_match("/^[\.A-z0-9_\-]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $comment_arr[2])){ $url_target = "";$mail_or_url = "mailto:"; }
    else{
    $url_target = "";
    $mail_or_url = "";
    if(substr($comment_arr[2],0,3) == "www"){ $mail_or_url = "http://"; }
    }

    $output = str_replace("{author}", "<a $url_target href=\"$mail_or_url".stripslashes($comment_arr[2])."\">".stripslashes($comment_arr[1])."</a>", $template_comment);
    }
    else{ $output = str_replace("{author}", $comment_arr[1], $template_comment); }
    $comment_arr[4] = run_filters('news-comment-content',$comment_arr[4]);
    $output = str_replace("{mail}", "$comment_arr[2]",$output);

    // Show commenters host hack - adding variable {host} (appelsinjuice.org)
    if (!!stristr($output, "{host}")) {
    if ($comment_arr[3] && $comment_arr[3] != "not detected") {
    $hostname = gethostbyaddr($comment_arr[3]);
    $hostname = "*." . substr($hostname, strpos($hostname, ".") + 1);
    $output = str_replace("{host}", $hostname, $output);
    }
    else {
    $output = str_replace("{host}", "no host", $output);
    }
    }
    // END Show commenters host

    $output = str_replace("{music}", "$comment_arr[7]",$output);

    // Admin hack part Two: Adding a template variable (appelsinjuice.org)
    if ($admin_posting == "TRUE") {
    $output = str_replace("{admin}", $config_admin_template,$output); }
    else { $output = str_replace("{admin}", "",$output); }
    // END Admin hack part Two

    $output = str_replace("{date}", date($config_timestamp_comment, $comment_arr[0]),$output);
    $output = str_replace("{date-local}", strftime($config_timestamp_local_comment, $comment_arr[0]), $output);
    $output = str_replace("{comment-id}", $comment_arr[0],$output);
    $comment_arr[4] = preg_replace("/\
    PHP Code:
    (.*)\[\/PHP\]/esiU", "php_string('$1')", $comment_arr[4]);
                        
    $output = str_replace("{comment}", "<a id=\"" ."C" .$comment_arr[0]."\"></a>$comment_arr[4]",$output);
                        
    // {comnum} & altcolors
                        
    if($i%== 0) {
                            
    $com_alternating "cn_comment_odd";
                        }
                        else {
                            
    $com_alternating "cn_comment_even";
                        }
                        
    $output str_replace("{alternating}"$com_alternating$output);
                        
    $i++;

                        
    $output str_replace("{comnum}"$cjnumber$output);
                        if (
    $config_reverse_comments == "yes") {
                            
    $cjnumber--;
                        }
                        else { 
    $cjnumber++; }
                        
    $output run_filters('news-comment',$output);
                        
    $output replace_comment("show"$output);
                        echo 
    $output;

                    }
                }
            }
        }

            
    // Comments Pagination
            
    if ($config_comments_pagination == "Yes") {
                
    $cprev_next_msg $template_cprev_next;
                
    $nextcstart $cstart $cnum;
                
    $prevcstart $cstart $cnum;
                
    $COM_REQUEST_URI $PHP_SELF "?" cute_query_string($QUERY_STRING, array("cstart"));

                
    // <--- Previous
                
    if($cstart>1+$cghost){
                    
    $cprev_next_msg preg_replace("'\[prev-link\](.*?)\[/prev-link\]'si""<a href=\"{$COM_REQUEST_URI}&amp;cstart={$prevcstart}\">\\1</a>"$cprev_next_msg);
                }
                else {
                    
    $cprev_next_msg preg_replace("'\[prev-link\](.*?)\[/prev-link\]'si""\\1"$cprev_next_msg); $no_cprev TRUE;
                }
                
    // |<-- Previous

                // {pages}
                
    $cnumadd 0;
                
    $cpages "";
                for(
    $k=1;$cnumadd<$total_comments;$k++){
                    
    $cstartnum $cnum*($k-1)+1+$cghost;
                    if(
    $cstartnum != $cstart) {
                        
    $cpages .= "<a href=\"{$COM_REQUEST_URI}&amp;cstart={$cstartnum}\">$k</a> ";
                    }
                    else {
                        
    $cpages .= " <strong>| $k |</strong> ";
                    }
                
    $cnumadd $cnum*$k;
                }
                
    $cprev_next_msg str_replace("{pages}"$cpages$cprev_next_msg);
                
    // {pages} |

                // Next -->
                
    if($cstart+$cnum-1-$cghost $total_comments) {
                    
    $cprev_next_msg preg_replace("'\[next-link\](.*?)\[/next-link\]'si""<a href=\"{$COM_REQUEST_URI}&amp;cstart={$nextcstart}\">\\1</a>"$cprev_next_msg);
                }
                else {
                    
    $cprev_next_msg preg_replace("'\[next-link\](.*?)\[/next-link\]'si""\\1"$cprev_next_msg); $no_cnext TRUE;
                }
                
    // Next -->|

                
    if (!$no_cprev or !$no_cnext){ echo $cprev_next_msg; }
            }
            
    // Comments Pagination

        
    $template_form str_replace("{config_http_script_dir}""$config_http_script_dir"$template_form);

        
    $smilies_form "\n<script type=\"text/javascript\">
        //<![CDATA[
        function insertext(text, spot){
        document.forms['comment'].elements['comments'].value += ' ' +text;
        }
        //]]></script>
        "
    .insertSmilies('short'FALSE);

        
    $template_form str_replace("{smilies}"$smilies_form$template_form);
        if (
    $_COOKIE['commentname']) { $template_form str_replace("{savedname}"$_COOKIE['commentname'], $template_form); } else { $template_form str_replace("{savedname}"""$template_form); }
        if (
    $_COOKIE['commentmail']) { $template_form str_replace("{savedmail}"$_COOKIE['commentmail'], $template_form); } else { $template_form str_replace("{savedmail}"""$template_form); }
        
    // rememberme input
        
    $template_form str_replace("{remember}","<input type=\"checkbox\" id=\"rememberme\" name=\"rememberme\" value=\"yes\" checked=\"checked\" />"$template_form);

        echo
    "<form method=\"post\" id=\"comment\" action=\"\">".$template_form."<div><input type=\"hidden\" name=\"javasubaction\" value=\"$subaction\" /><input type=\"hidden\" name=\"subaction\" value=\"addcomment\" /><input type=\"hidden\" name=\"ucat\" value=\"$ucat\" /><input type=\"hidden\" name=\"show\" value=\"$show\" />$user_post_query</div></form>";

    }





    if( 
    substr($my_q, -5) == "&amp;" ){ $my_q substr($my_q0, -5); }

    return 
    $my_q;
    }


    //##############################################################################  ######################################
    //         Active News
    //##############################################################################  ######################################
    if($allow_active_news){

        
    $all_news file("$news_file");

            
    // stupid hack for sorting dates
            // if ($config_sortbydate == "yes") {
            
    asort($all_news);
            
    reset($all_news);
            
    $all_news array_reverse($all_news);
            
    // }

        
    if($reverse == TRUE){ $all_news array_reverse($all_news); }
        
    $all_news run_filters('news-recordset',$all_news);
        
    $count_all 0;
        if(isset(
    $category) and $category != ""){
            foreach(
    $all_news as $news_line){
                
    $news_arr explode("|"$news_line);
                if(
    $requested_cats and $requested_cats[$news_arr[6]] == TRUE){ $count_all ++; }
                else{ continue; }
            }
        }else{ 
    $count_all count($all_news); }
        
    // Sort News v1.0 - End addblock
        
    if (!empty($sortby)) {
        if (!
    function_exists('sortcmp')) {
         function 
    sortcmp($a$b) {
          global 
    $all_news$sortby;

          
    $news_a explode('|'$all_news[$a]);
          
    $news_b explode('|'$all_news[$b]);

          return 
    strnatcasecmp($news_a[$sortby], $news_b[$sortby]);
         }
        }
        
    uksort($all_news'sortcmp');
        unset(
    $sortby);
        }
        
    // Sort News v1.0 - End addblock
        
    $i 0;
        
    $o 0;
        
    $showed 0;
        
    $repeat TRUE;
        
    $url_archive $archive;

        while(
    $repeat != FALSE){

            foreach(
    $all_news as $news_line){

               
    $news_arr explode("|"$news_line);
               
    /*
            // prospective posting
            $nowtime = time() + ($config_date_adjust * 60);
            if (($config_prospective == "On" and $nowtime <= $news_arr[0])) {
            $count_all--;
            continue;
            }*/
            
    $modifier run_filters('news-loop''');

            if (
    $modifier == "skip") {
                
    $count_all--;
                continue;
                }

            if(
    $category and $requested_cats[$news_arr[6]] != TRUE){ continue; }

            if(isset(
    $start_from) and $start_from != ""){
                if(
    $i $start_from){
                    
    $i++;
                    continue; }
                elseif(
    $showed == $number){  break; }
            }

            if(
    $my_names[$news_arr[1]]){ $my_author $my_names[$news_arr[1]]; }
            else{ 
    $my_author $news_arr[1]; }

            
    $output $template_active;
            
    // TEIT highlight-HACK
            
    if($highlight) {
                
    $news_arr[3] = str_replace($highlight"<em>$highlight</em>"$news_arr[3]);
                }
            
    // end teit highlight-hack
            // alternating
            
    if($o%== 0) { $nws_alternating "cn_news_odd"; } else { $nws_alternating "cn_news_even"; }
            
    $output str_replace("{alternating}"$nws_alternating$output);
            
    $o++;
            
    $output str_replace("{title}"$news_arr[2], $output);

            
    // Add DATE variable to active news template
            
    $output str_replace("{date}"date($config_timestamp_active$news_arr[0]), $output);
            
    $output str_replace("{date-local}"strftime($config_timestamp_local_active$news_arr[0]), $output);
            
    // END Add DATE variable to AN
            
    $output str_replace("{author}"$my_author$output);
            if(
    $news_arr[5] != ""){$output str_replace("{avatar}""<img alt=\"\" src=\"$news_arr[5]\" style=\"border: none;\" />"$output); }
            else{ 
    $output str_replace("{avatar}"""$output); }
            
    $output str_replace("{avatar-url}""$news_arr[5]"$output);

        
    // Music hack by rilmith 3 lines below.
        
    if ($news_arr[7] != "") {
        
    $output str_replace("{music}"$news_arr[7], $output); }
        else { 
    $output str_replace("{music}"$config_music_empty$output); }

            
    $output str_replace("[link]","<a title=\"$lang_article_linktext\" href=\"$PHP_SELF?subaction=showfull&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]&amp;$user_query\">"$output);
            
    $output str_replace("[/link]","</a>"$output);
            
    $output str_replace("{comments-num}"countComments($news_arr[0], $archive), $output);
            
    $output str_replace("{short-story}"run_filters('news-entry-content',$news_arr[3]), $output);
            
    $output str_replace("{full-story}"run_filters('news-entry-content',$news_arr[4]), $output);
            
    $output str_replace("{category}"$cat[$news_arr[6]], $output);
            
    $output str_replace("{category-id}"$news_arr[6], $output);
            if(
    $cat_icon[$news_arr[6]] != ""){ $output str_replace("{category-icon}""<img alt=\"".$cat[$news_arr[6]]." icon\" style=\"border: none;\" src=\"".$cat_icon[$news_arr[6]]."\" />"$output); }
            else{ 
    $output str_replace("{category-icon}"""$output); }

            
    $output str_replace("{author-name}"$name_to_nick[$news_arr[1]], $output);

             if(
    $my_mails[$news_arr[1]] != ""){
                 
    $output str_replace("[mail]","<a href=\"mailto:".$my_mails[$news_arr[1]]."\">"$output);
                 
    $output str_replace("[/mail]","</a>"$output);
            }else{
                 
    $output str_replace("[mail]",""$output);
                 
    $output str_replace("[/mail]",""$output);
             }
            
    // RSS
            
    $output str_replace("{rssmail}"$my_mails[$news_arr[1]], $output);
            
    $output str_replace("{rssdate}"date("r"$news_arr[0]), $output);
            
    $output str_replace("{rssauthor}"$news_arr[1], $output);
            
    // end rss
            
    $output str_replace("{news-id}"$news_arr[0], $output);
            
    $output str_replace("{archive-id}"$archive$output);
            
    $output str_replace("{php-self}"$PHP_SELF$output);
            
    $output str_replace("{cute-http-path}"$config_http_script_dir$output);

    // XFields v2.1 - addblock
    $xfieldsaction "templatereplace";
    $xfieldsinput $output;
    $xfieldsid $news_arr[0];
    include(
    "xfields.mdu");
    $output $xfieldsoutput;
    // XFields v2.1 - End addblock

            
    $output run_filters('news-entry',$output);
            
    $output replace_news("show"$output);


            if(
    $news_arr[4] != "" or $action == "showheadlines"){//if full story
                
    if($config_full_popup == "yes"){

                    
    $output preg_replace("/\\[full-link\\]/","<a href=\"#\" onclick=\"window.open('$config_http_script_dir/show_news.php?subaction=showfull&amp;id=$news_arr[0]&amp;archive=$archive&amp;template=$template', '_News', '$config_full_popup_string');return false;\">"$output);
                }else{
                    
    $output str_replace("[full-link]","<a href=\"$PHP_SELF?subaction=showfull&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]&amp;$user_query\">"$output);
                }
                    
    $output str_replace("[/full-link]","</a>"$output);
            }else{
                
    $output preg_replace("'\\[full-link\\].*?\\[/full-link\\]'si","<!-- no full story-->"$output);
            }

    //        $output = run_filters('news-active-comlink', $output);
            
    if($config_comments_popup == "yes"){
                
    $output str_replace("[com-link]","<a href=\"#\" onclick=\"window.open('$config_http_script_dir/show_news.php?subaction=showcomments&amp;template=$template&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]', '_News', '$config_comments_popup_string');return false;\">"$output);
            }else{
                
    $output str_replace("[com-link]","<a href=\"$PHP_SELF?subaction=showcomments&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]&amp;$user_query\">"$output);
            }

            
    $output str_replace("[/com-link]","</a>"$output);

    // AJB Date header option (based on code by SMKILLER2, rescued by The Dude)
    if ($config_date_header == "Yes") {
        if (
    $dateheader_S != date("dmY"$news_arr[0])) {
            
    // 161-hacks above and below
            
    $dateheader_S date("dmY"$news_arr[0]);

            
    $dateheader date($config_date_headerformat$news_arr[0]);
            
    $dateheader_local strftime($config_date_headerformatlocal$news_arr[0]);
            
    $dateheader_p $template_dateheader;
            
    $dateheader_p str_replace("{dateheader}"$dateheader$dateheader_p);
            
    $dateheader_p str_replace("{dateheader-local}"strftime($dateheader_local$news_arr[0]), $dateheader_p);

             echo 
    $dateheader_p;
            }
        }
    // End AJB Date header option



            
    echo $output;
            
    $showed++;
            
    $i++;

            if(
    $number != and $number == $i){ break; }
            }
            
    $used_archives[$archive] = TRUE;
    // Archives Looop
            
    if($i $number and $only_active != TRUE){

                if(!
    $handle opendir("$cutepath/data/archives")){ die("<div style=\"text-align: center;\">$lang_archive_notopen</div>"); }
                     while (
    false !== ($file readdir($handle)))
                     {
                         if(
    $file != "." and $file != ".." and eregi("news.arch"$file))
                         {
                             
    $file_arr explode(".",$file);
                            
    $archives_arr[$file_arr[0]] = $file_arr[0];
                         }
                     }
                
    closedir($handle);

                
    $archives_arr[$in_use]="";
                
    $in_use max($archives_arr);

                if(
    $in_use != "" and !$used_archives[$in_use]){
                    
    $all_news file("$cutepath/data/archives/$in_use.news.arch");
                    
    $archive $in_use;
                    
    $used_archives[$in_use] = TRUE;
                }else{ 
    $repeat FALSE; }

            }else{ 
    $repeat FALSE; }
        }

    // << Previous   &   Next >>

        
    $prev_next_msg $template_prev_next;

        
    //----------------------------------
        // Previous link
        //----------------------------------
        
    if(isset($start_from) and $start_from != "" and $start_from 0){
            
    $prev $start_from $number;
            
    $prev_next_msg preg_replace("'\[prev-link\](.*?)\[/prev-link\]'si""<a href=\"$PHP_SELF?start_from=$prev&amp;archive=$url_archive&amp;subaction=$subaction&amp;id=$id&amp;$u  ser_query\">\\1</a>"$prev_next_msg);
        }else{ 
    $prev_next_msg preg_replace("'\[prev-link\](.*?)\[/prev-link\]'si""\\1"$prev_next_msg); $no_prev TRUE; }

        
    //----------------------------------
        // Pages
        //----------------------------------
        
    if($number){
        
    $pages_count = @ceil($count_all/$number);
        
    $pages_start_from 0;
        
    $pages "";
        for(
    $j=1;$j<=$pages_count;$j++){
            if(
    $pages_start_from != $start_from){ $pages .= "<a href=\"$PHP_SELF?start_from=$pages_start_from&amp;archive=$url_archive&amp;subaction=$subacti  on&amp;id=$id&amp;$user_query\">$j</a> "; }
            else{ 
    $pages .= " <strong>| $j |</strong> "; }
            
    $pages_start_from += $number;
        }
        
    $prev_next_msg str_replace("{pages}"$pages$prev_next_msg);
        }
        
    //----------------------------------
        // Next link
        //----------------------------------
        
    if($number $count_all and $i $count_all){
            
    $prev_next_msg preg_replace("'\[next-link\](.*?)\[/next-link\]'si""<a href=\"$PHP_SELF?start_from=$i&amp;archive=$url_archive&amp;subaction=$subaction&amp;id=$id&amp;$user  _query\">\\1</a>"$prev_next_msg);
        }else{ 
    $prev_next_msg preg_replace("'\[next-link\](.*?)\[/next-link\]'si""\\1"$prev_next_msg); $no_next TRUE;}


        if    (!
    $no_prev or !$no_next){ echo $prev_next_msg; }
    }
    }while(
    0);
    ?> 

  22. #22
    SitePoint Enthusiast Anders N's Avatar
    Join Date
    Dec 2004
    Location
    Norway
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Works great, but another error on the original page (index2.php):

    Fatal error: Cannot redeclare replace_news() (previously declared in /usr/home/web/wno32422/bakgrunner/inc/functions.inc.php:293) in /usr/home/web/wno32422/ringetoner/inc/shows.inc.php on line 16

  23. #23
    SitePoint Enthusiast Anders N's Avatar
    Join Date
    Dec 2004
    Location
    Norway
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, got another error too. When i press a show full news link, nothing gets printed...
    http://mobilmoro.net/ringetoneropen...._from=&ucat=8&

  24. #24
    Free Geek computerages's Avatar
    Join Date
    Oct 2004
    Location
    /dev/null
    Posts
    1,071
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alright, put the following code in ringetoner/inc/functions.inc.php:
    PHP Code:

    <?PHP

    if(!$PHP_SELF){
        if(
    $HTTP_POST_VARS)     {extract($HTTP_POST_VARSEXTR_PREFIX_SAME"post_");}
        if(
    $HTTP_GET_VARS)      {extract($HTTP_GET_VARSEXTR_PREFIX_SAME"get_");}
        if(
    $HTTP_COOKIE_VARS)    {extract($HTTP_COOKIE_VARSEXTR_PREFIX_SAME"cookie_");}
        if(
    $HTTP_ENV_VARS)         {extract($HTTP_ENV_VARSEXTR_PREFIX_SAME"env_");}
    }
    if(
    $PHP_SELF == ""){ $PHP_SELF $HTTP_SERVER_VARS["PHP_SELF"]; }

    ///////////////////////////////////////////////////////
    // Function:     formatsize
    // Description: Format the size of given file
    if ( ! function_exists('formatsize') ) {
    function 
    formatsize($file_size){
        if(
    $file_size >= 1073741824)
            {
    $file_size round($file_size 1073741824 100) / 100 "GB";}
        elseif(
    $file_size >= 1048576)
            {
    $file_size round($file_size 1048576 100) / 100 "MB";}
        elseif(
    $file_size >= 1024)
            {
    $file_size round($file_size 1024 100) / 100 "KB";}
        else{
    $file_size $file_size "b";}
    return 
    $file_size;
    }
    }
    ///////////////////////////////////////////////////////
    // Class:     microTimer
    // Description: calculates the micro time

    if ( ! class_exists('microTimer') ) {

    class 
    microTimer {
        function 
    start() {
            global 
    $starttime;
            
    $mtime microtime ();
            
    $mtime explode (' '$mtime);
            
    $mtime $mtime[1] + $mtime[0];
            
    $starttime $mtime;
        }
        function 
    stop() {
            global 
    $starttime;
            
    $mtime microtime ();
            
    $mtime explode (' '$mtime);
            
    $mtime $mtime[1] + $mtime[0];
            
    $endtime $mtime;
            
    $totaltime round (($endtime $starttime), 5);
            return 
    $totaltime;
        }
    }
    }
    ///////////////////////////////////////////////////////
    // Function:     check_login
    // Description: Check login information

    if ( ! function_exists('check_login') ) {

    function 
    check_login($username$md5_password){
        
    $result