[CMS][Tutorial] How to Fix the post News

Reis

New Member
Sep 29, 2011
3
1
Hello, I'm Lucas Reis, owner of:

I've fixed the PHP to post the correct news without the HTML tags.

If you want this fixed, go to:

Your style > hk > news2.php

In the 66 line, remove the Filter tag in the ["longstory"], eg:

PHP:
    mysql_query("INSERT INTO cms_news (title,shortstory,longstory,published,image,author, campaign, campaignimg) VALUES ('" . filter($_SESSION["title"]) . "', '" . filter($_SESSION["shortstory"]) . "', '" . ($_SESSION["longstory"]) . "', '" . time() . "', '" . filter($_POST["topstory"]) . "', '" . filter($author) . "', 0, 'default')") or die(mysql_error());

Save the document and test to post the news.

Or download:
Attached document.

This realy work.

Credits:
Kryptos - RevCms coder
Me - Fixing the post News
 

Attachments

  • news2.zip
    1.5 KB · Views: 238

Kryptos

prjRev.com
Jul 21, 2010
2,205
1,252
Yea but that'd make it exploitable...

Just change the filter tag with mysql_real_escape_string..

Like so,

PHP:
mysql_query("INSERT INTO cms_news (title,shortstory,longstory,published,image,author, campaign, campaignimg) VALUES ('" . filter($_SESSION["title"]) . "', '" . filter($_SESSION["shortstory"]) . "', '" . mysql_real_escape_string($_SESSION["longstory"]) . "', '" . time() . "', '" . filter($_POST["topstory"]) . "', '" . filter($author) . "', 0, 'default')") or die(mysql_error());

USE MY QUERY ABOVE, NOT THE ONE IN THE THREAD.
 

Online

Member
Sep 19, 2010
135
23
Er, what if that still doesnt fix it?
"Incorrect integer value: 'Codeh' for column 'author' at row 1"
 

JeeCee

Member
Jan 15, 2012
96
7
Yea but that'd make it exploitable...

Just change the filter tag with mysql_real_escape_string..

Like so,

PHP:
mysql_query("INSERT INTO cms_news (title,shortstory,longstory,published,image,author, campaign, campaignimg) VALUES ('" . filter($_SESSION["title"]) . "', '" . filter($_SESSION["shortstory"]) . "', '" . mysql_real_escape_string($_SESSION["longstory"]) . "', '" . time() . "', '" . filter($_POST["topstory"]) . "', '" . filter($author) . "', 0, 'default')") or die(mysql_error());

USE MY QUERY ABOVE, NOT THE ONE IN THE THREAD.
If I do that, and I post a news item, and I go to the news page to see that item, I still got the \r\n in the news item, instead of a black 'enter'
 

Kryptos

prjRev.com
Jul 21, 2010
2,205
1,252
If I do that, and I post a news item, and I go to the news page to see that item, I still got the \r\n in the news item, instead of a black 'enter'
Try this, then:

It should act as a '<br>' wherever it says '\n' or '\r', etc.
PHP:
mysql_query("INSERT INTO cms_news (title,shortstory,longstory,published,image,author, campaign, campaignimg) VALUES ('" . filter($_SESSION["title"]) . "', '" . filter($_SESSION["shortstory"]) . "', '" . nl2br(mysql_real_escape_string($_SESSION["longstory"])) . "', '" . time() . "', '" . filter($_POST["topstory"]) . "', '" . filter($author) . "', 0, 'default')") or die(mysql_error());
 

JeeCee

Member
Jan 15, 2012
96
7
Try this, then:

It should act as a '<br>' wherever it says '\n' or '\r', etc.
PHP:
mysql_query("INSERT INTO cms_news (title,shortstory,longstory,published,image,author, campaign, campaignimg) VALUES ('" . filter($_SESSION["title"]) . "', '" . filter($_SESSION["shortstory"]) . "', '" . nl2br(mysql_real_escape_string($_SESSION["longstory"])) . "', '" . time() . "', '" . filter($_POST["topstory"]) . "', '" . filter($author) . "', 0, 'default')") or die(mysql_error());
Hmpf, tried that, stil got the error.

P.S. got a screenie here:
14lqck2.png
 

Users who are viewing this thread

Top