Browse Source

PHP ctype_digit

Utilisation d'une fonction plus appropriée pour tester si une chaîne
représente un nombre entier
Corrige un bug de date
Alexandre Alapetite 12 năm trước cách đây
mục cha
commit
baa8d21341
3 tập tin đã thay đổi với 6 bổ sung6 xóa
  1. 1 1
      app/models/Entry.php
  2. 3 3
      app/models/Feed.php
  3. 2 2
      app/models/RSSConfiguration.php

+ 1 - 1
app/models/Entry.php

@@ -106,7 +106,7 @@ class Entry extends Model {
 		$this->link = $value;
 	}
 	public function _date ($value) {
-		if (is_int ($value)) {
+		if (ctype_digit ($value)) {
 			$this->date = intval ($value);
 		} else {
 			$this->date = time ();

+ 3 - 3
app/models/Feed.php

@@ -150,7 +150,7 @@ class Feed extends Model {
 		$this->lastUpdate = $value;
 	}
 	public function _priority ($value) {
-		$this->priority = is_numeric ($value) ? intval ($value) : 10;
+		$this->priority = ctype_digit ($value) ? intval ($value) : 10;
 	}
 	public function _pathEntries ($value) {
 		$this->pathEntries = $value;
@@ -175,10 +175,10 @@ class Feed extends Model {
 		$this->keep_history = $value;
 	}
 	public function _nbNotRead ($value) {
-		$this->nbNotRead = is_numeric ($value) ? intval ($value) : -1;
+		$this->nbNotRead = ctype_digit ($value) ? intval ($value) : -1;
 	}
 	public function _nbEntries ($value) {
-		$this->nbEntries = is_numeric ($value) ? intval ($value) : -1;
+		$this->nbEntries = ctype_digit ($value) ? intval ($value) : -1;
 	}
 
 	public function load () {

+ 2 - 2
app/models/RSSConfiguration.php

@@ -171,7 +171,7 @@ class RSSConfiguration extends Model {
 		$this->language = $value;
 	}
 	public function _postsPerPage ($value) {
-		if (is_int (intval ($value)) && $value > 0) {
+		if (ctype_digit ($value) && $value > 0) {
 			$this->posts_per_page = $value;
 		} else {
 			$this->posts_per_page = 10;
@@ -216,7 +216,7 @@ class RSSConfiguration extends Model {
 		$this->sort_order = $value === 'ASC' ? 'ASC' : 'DESC';
 	}
 	public function _oldEntries ($value) {
-		if (is_int (intval ($value)) && $value > 0) {
+		if (ctype_digit ($value) && $value > 0) {
 			$this->old_entries = $value;
 		} else {
 			$this->old_entries = 3;