Fixed bug #522241, convert special chars to html entities

This commit is contained in:
h-alstad committed 2010-03-02 21:27:01 +01:00
1 parent a99c9bbdd1
commit 0ef287b2b7
1 file changed
+24 -24
+24 -24
View File
@@ -19,7 +19,7 @@ class Article {
public $updated_by;
public $updated_at;
public $expires;
public $conn;
@@ -30,7 +30,7 @@ class Article {
if ($id == NULL){//New article
if ($data == NULL){
error('Article: No data supplied.');
error('Article: No data supplied.');
}else {
$this->author = getCurrentUserName();
$this->updated_by = getCurrentUserName();
@@ -40,25 +40,25 @@ class Article {
}else {//ID set, existing article
if ($data != NULL){//Update existing article
$this->updated_by = getCurrentUserName();
//primary attachment
if($_FILES['attachment1']['error'] != 4){
$temp_name = new_file($_FILES['attachment1'], 'nyheter');
rename_file($temp_name, $this->id, 'nyheter');
$this->attachment1 = $this->id.substr($temp_name, -4);
}else {
$this->attachment1 = 0;
$this->attachment1 = 0;
}
//secondary attachment
if($_FILES['attachment2']['error'] != 4){
$temp_name = new_file($_FILES['attachment2'], 'nyheter');
rename_file($temp_name, $this->id.'_2', 'nyheter');
$this->attachment2 = $this->id.'_2'.substr($temp_name, -4);
}else {
$this->attachment2 = 0;
$this->attachment2 = 0;
}
}else {//Retrieve data from backend for display or other actions
$data = $this->_retrieveData();
$this->date = $data['date'];
@@ -70,8 +70,8 @@ class Article {
}
}
//Common initializations
$this->title = $data['title'];
$this->intro = stripcslashes($data['intro']);
$this->title = htmlspecialchars(stripslashes($data['title']));
$this->intro = stripcslashes($data['intro']);
$this->text = stripcslashes($data['text']);
$this->caption1 = $data['caption1'];
$this->caption2 = $data['caption2'];
@@ -103,16 +103,16 @@ class Article {
rename_file($temp_name, $this->id, 'nyheter');
$this->attachment1 = $this->id.substr($temp_name, -4);
}else {
$this->attachment1 = 0;
$this->attachment1 = 0;
}
//secondary attachment
if($_FILES['attachment2']['error'] != 4){
$temp_name = new_file($_FILES['attachment2'], 'nyheter');
rename_file($temp_name, $this->id.'_2', 'nyheter');
$this->attachment2 = $this->id.'_2'.substr($temp_name, -4);
}else {
$this->attachment2 = 0;
$this->attachment2 = 0;
}
$this->_storeFilenames();
@@ -122,7 +122,7 @@ class Article {
error("New article: " . $result->toString());
}
}else {
$sql = sprintf("UPDATE nyhet SET
$sql = sprintf("UPDATE nyhet SET
tittel = %s,
ingress = %s,
tekst = %s,
@@ -131,7 +131,7 @@ class Article {
caption2 = %s,
sistEndretAv = %s,
sistEndret = NOW()
WHERE
WHERE
id = %s",
$this->conn->quoteSmart($this->title),
$this->conn->quoteSmart($this->intro),
@@ -181,8 +181,8 @@ class Article {
public function delete($id){
$conn = db_connect();
$sql = "DELETE FROM nyhet
WHERE id = $id
$sql = "DELETE FROM nyhet
WHERE id = $id
LIMIT 1";
$result = $conn->query($sql);
if (DB::isError($result) != true){
@@ -213,35 +213,35 @@ class Article {
print('</div>');
}
print('</div>');
//$text = str_replace("[img2]", $this->_text_insert_attachment($this->attachment2, $this->caption2), $this->text);
$text = str_replace('[img2]', '', $this->text);
?>
<h3><?php print $this->title; ?></h3>
<p class="date"><?php print formatDate($this->date); ?></p>
<p class="date"><?php print formatDate($this->date); ?></p>
<p class="intro"><?php print prepareForHTML($this->intro); ?></p>
<p class="text"><?php print $text; ?></p>
<?php
}
public function displayList(){
?>
<tr>
<td><a href="index.php?page=display-article&amp;articleid=<?php print $this->id; ?>"><?php print $this->title; ?></a></td>
<td><?php print prepareForHTML($this->intro); ?></td>
<td><?php print $this->author; ?></td>
<td class="date"><?php print formatDate($this->date, "td"); ?></td>
<td class="date"><?php print formatDate($this->expires, "td"); ?></td>
<td class="date"><?php print formatDate($this->date, "td"); ?></td>
<td class="date"><?php print formatDate($this->expires, "td"); ?></td>
<?php displayOptionsMenuTable($this->id, ARTICLE, "article", "view-edit-options-article"); ?>
</tr>
<?php
}
private function _text_insert_attachment($file, $caption) {
$string = "";
if (!empty($file)){
@@ -254,7 +254,7 @@ class Article {
}
return $string;
}
private function _storeFilenames() {
if ($this->attachment1 != 0) {
$sql = "UPDATE nyhet SET vedlegg = '$this->attachment1' WHERE id = $this->id";