diff --git a/inside/Article.php b/inside/Article.php index cd0dce3..cfc7604 100644 --- a/inside/Article.php +++ b/inside/Article.php @@ -45,7 +45,8 @@ class Article { 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); + $ext = strtolower( pathinfo($temp_name, PATHINFO_EXTENSION) ); + $this->attachment1 = $this->id . "." . $ext; }else { $this->attachment1 = 0; } @@ -54,7 +55,8 @@ class Article { 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); + $ext = strtolower( pathinfo($temp_name, PATHINFO_EXTENSION) ); + $this->attachment2 = $this->id . "_2." . $ext; }else { $this->attachment2 = 0; } @@ -101,7 +103,8 @@ class Article { 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); + $ext = strtolower( pathinfo($temp_name, PATHINFO_EXTENSION) ); + $this->attachment1 = $this->id . "." . $ext; }else { $this->attachment1 = 0; } @@ -110,7 +113,8 @@ class Article { 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); + $ext = strtolower( pathinfo($temp_name, PATHINFO_EXTENSION) ); + $this->attachment1 = $this->id . "_2." . $ext; }else { $this->attachment2 = 0; } @@ -267,4 +271,4 @@ class Article { } } -?> \ No newline at end of file +?> diff --git a/inside/Concert.php b/inside/Concert.php index 3702dbe..84fc638 100644 --- a/inside/Concert.php +++ b/inside/Concert.php @@ -80,7 +80,8 @@ class Concert { if( $_FILES['userfile']['error'] != 4 ) { $temp_name = new_file($_FILES['userfile'], "program"); rename_file($temp_name, $this->id, "program"); - $this->picture = $this->id.substr($temp_name, -4); + $ext = strtolower( pathinfo($temp_name, PATHINFO_EXTENSION) ); + $this->picture = $this->id . "." . $ext; } $this->links = $data['links']; @@ -142,8 +143,8 @@ class Concert { $this->id = getNextId("program"); if($_FILES['userfile']['error'] != 4){ $temp_name = new_file($_FILES['userfile'], "program"); - rename_file($temp_name, $this->id, "program"); - $ext = strtolower( pathinfo($temp_name, PATHINFO_EXTENSION) ); + rename_file($temp_name, $this->id, "program"); + $ext = strtolower( pathinfo($temp_name, PATHINFO_EXTENSION) ); $this->picture = $this->id . "." . $ext; } else { $this->picture = "0"; diff --git a/inside/Division.php b/inside/Division.php index 4f973de..785c9ef 100644 --- a/inside/Division.php +++ b/inside/Division.php @@ -81,10 +81,11 @@ class Division { } }else {//ID set, existing article if ($data != NULL){//Update existing article - if($_FILES['userfile']['error'] != 4){ - $temp_name = new_file($_FILES, "foreninger"); + if($_FILES['userfile']['error'] != 4) { + $temp_name = new_file($_FILES['userfile'], "foreninger"); rename_file($temp_name, $this->id, "foreninger"); - $this->picture = $this->conn->quoteSmart($this->id.substr($temp_name, -4)); + $ext = strtolower( pathinfo($temp_name, PATHINFO_EXTENSION) ); + $this->picture = $this->id . "." . $ext; }else { $this->picture = "picture"; } diff --git a/inside/Product.php b/inside/Product.php index 17d5977..5e969fc 100644 --- a/inside/Product.php +++ b/inside/Product.php @@ -34,7 +34,8 @@ class Product { if($_FILES['userfile']['error'] != 4){ $temp_name = new_file($_FILES['userfile'], 'products'); rename_file($temp_name, $this->id, 'products'); - $this->picture = $this->id.substr($temp_name, -4); + $ext = strtolower( pathinfo($temp_name, PATHINFO_EXTENSION) ); + $this->picture = $this->id . "." . $ext; }else { $this->picture = 0; } @@ -72,7 +73,8 @@ class Product { if($_FILES['userfile']['error'] != 4){ $temp_name = new_file($_FILES['userfile'], 'products'); rename_file($temp_name, $this->id, 'products'); - $this->picture = $this->id.substr($temp_name, -4); + $ext = strtolower( pathinfo($temp_name, PATHINFO_EXTENSION) ); + $this->picture = $this->id . "." . $ext; }else { $this->picture = 0; } @@ -334,4 +336,4 @@ AND t.status = 'OK' " . } } -?> \ No newline at end of file +?>