Topic: CN1.5: print.php doesn't work

In Cutenews 1.5 I've noted doesn't work print.php hack. How to fix it?

Re: CN1.5: print.php doesn't work

Can help to rewrite print.php cutenews 1.5 but where can I get it?

Re: CN1.5: print.php doesn't work

Can help to rewrite print.php cutenews 1.5 but where can I get it?


This is the file print.php I put in Cutenews folder:

<div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'><?PHP

error_reporting (E_ALL ^E_NOTICE);
require_once("./inc/functions.inc.php");
require_once("./data/config.php");
//$PHP_SELF = "";

if($id != ""){

    if($archive != ""){ $news_file = "./data/archives/$archive.news.arch"; }
    else{ $news_file = "./data/news.txt"; }

    $all_news = file("$news_file");
    $found = FALSE;
    foreach($all_news as $news_line){
        $news_arr = explode("|", $news_line);
        if($news_arr[0] == $id){ $found = TRUE; break;}
    }
    if($found == TRUE){
        $title    = $news_arr[2];
        $date    = date("j F Y h:i A", $news_arr[0]);
        if($news_arr[4] != ""){
            $news    = replace_news("show", $news_arr[4]);
        }else{
            $news    = replace_news("show", $news_arr[3]);
        }

echo<<<PRINTABLE
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Printer Friendly Version</title>
</HEAD>
<BODY bgcolor="#ffffff" text="#000000" onload="window.print()">

$title @ <small>$date</small>
<hr>
$news
<hr>
<small>News powered by CuteNews - https://cutephp.com&lt;/small&gt;

</BODY>
</HTML>
PRINTABLE;

    }else{
        echo"The news you what to print was not found.";
    }

}else{ echo"No"; }

?></div>

Than in my temaplates I insert this code to the printer-friendly version:

<div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'>print</div>

Re: CN1.5: print.php doesn't work

please, help me

5 (edited by 2012-08-21 05:11:34)

Re: CN1.5: print.php doesn't work

It is necessary to replace the code print.php this:

<?PHP require_once("core/init.php");

if ($id != "") {
    $archive = preg_replace('~[^a-z0-9_]~i', '', $archive);
    if (!empty($archive) && isset($archive))
         $news_file = SERVDIR."/cdata/archives/$archive.news.arch";
    else $news_file = SERVDIR."/cdata/news.txt";

    $found = FALSE;
    $all_news = file($news_file);
    foreach ($all_news as $news_line) {
        $news_arr = explode("|", $news_line);
        if($news_arr[0] == $id) { $found = TRUE; break; }
    }
    if ($found == TRUE) {
        $title = $news_arr[2];
        $date = date("j F Y h:i A", $news_arr[0]);
        if ($news_arr[4] != "") { $news = replace_news("show", $news_arr[4]); }
        else { $news = replace_news("show", $news_arr[3]); }

echo<<<PRINTABLE
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Printer Friendly Version</title>
</HEAD>
<BODY bgcolor="#ffffff" text="#000000" onload="window.print()">
[b]$title[/b] @ <small>$date</small><hr>$news<hr>
<small>News powered by CuteNews - https://cutephp.com</small>

</BODY>
</HTML>
PRINTABLE;
} else { echo "The news you what to print was not found"; } 
}
else { echo "no id"; }
?>