CuteNews

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> CN1.5: print.php doesn't work
marnevi
post Aug 16 2012, 11:45 AM
Post #1


Member
**

Group: Members
Posts: 126
Joined: 16-May 10
Member No.: 43,597



In Cutenews 1.5 I've noted doesn't work print.php hack. How to fix it?
Go to the top of the page
 
+Quote Post
Dolphin
post Aug 16 2012, 11:57 AM
Post #2


Newbie
*

Group: Members
Posts: 14
Joined: 28-March 12
Member No.: 75,890



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


--------------------
I am a GIT'er Cutenews!
Go to the top of the page
 
+Quote Post
marnevi
post Aug 17 2012, 06:57 AM
Post #3


Member
**

Group: Members
Posts: 126
Joined: 16-May 10
Member No.: 43,597



QUOTE (Dolphin @ Aug 16 2012, 11:57 AM) *
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:

CODE
<?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()">

<b>$title</b> @ <small>$date</small>
<hr>
$news
<hr>
<small>News powered by CuteNews - http://cutephp.com</small>

</BODY>
</HTML>
PRINTABLE;

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

}else{ echo"No"; }

?>


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

CODE
<a href="{cute-http-path}/print.php?id={news-id}&archive={archive-id}">print</a>
Go to the top of the page
 
+Quote Post
marnevi
post Aug 20 2012, 04:12 PM
Post #4


Member
**

Group: Members
Posts: 126
Joined: 16-May 10
Member No.: 43,597



please, help me
Go to the top of the page
 
+Quote Post
Dolphin
post Aug 21 2012, 05:10 AM
Post #5


Newbie
*

Group: Members
Posts: 14
Joined: 28-March 12
Member No.: 75,890



It is necessary to replace the code print.php this:
CODE
<?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 - http://cutephp.com</small>

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


This post has been edited by Dolphin: Aug 21 2012, 05:11 AM


--------------------
I am a GIT'er Cutenews!
Go to the top of the page
 
+Quote Post

Fast ReplyReply to this topicStart new topic

 



RSS Lo-Fi Version Time is now: 19th May 2013 - 12:00 AM