From 0cffb7b27d00110d1531da050c6f0380ea70613e Mon Sep 17 00:00:00 2001
From: Charles Bovy <charles.bovy@gmail.com>
Date: Mon, 18 Apr 2016 16:17:39 +0200
Subject: [PATCH] Remove/changed some deprecated PHP7 functions: * split() by
preg_split() * eregi() by preg_match() * mysql_*() by mysqli_*() * PHP4
constructors (http://cweiske.de/tagebuch/php4-constructors-php7.htm)
---
classes/Database/Query/mysql.php | 30 +++++++++----------
classes/Database/mysql.php | 14 ++++-----
classes/vcalendar.php | 40 ++++++++++++++++++++------
includes/sorting.php | 2 +-
modules/music/mp3act_functions.php | 18 ++++++------
modules/mythweb/tmpl/default/set_flvplayer.php | 2 +-
modules/tv/classes/Recording.php | 5 +++-
7 files changed, 69 insertions(+), 42 deletions(-)
diff --git a/classes/Database/Query/mysql.php b/classes/Database/Query/mysql.php
index f05ddc2..b5e2cf1 100644
a
|
b
|
class Database_Query_mysql extends Database_Query { |
54 | 54 | $arg = array_shift($args); |
55 | 55 | $this->last_query .= is_null($arg) |
56 | 56 | ? 'NULL' |
57 | | : "'".mysql_real_escape_string($arg)."'"; |
| 57 | : "'".mysqli_real_escape_string($arg)."'"; |
58 | 58 | } |
59 | 59 | } |
60 | 60 | // Perform the query |
… |
… |
class Database_Query_mysql extends Database_Query { |
63 | 63 | $this->db->error(); |
64 | 64 | trigger_error($this->db->error, E_USER_ERROR); |
65 | 65 | } |
66 | | $this->sh = mysql_query($this->last_query, $this->dbh); |
| 66 | $this->sh = mysqli_query($this->last_query, $this->dbh); |
67 | 67 | |
68 | 68 | // Cache these |
69 | 69 | if (is_bool($this->sh)) { |
70 | | $this->insert_id = mysql_insert_id($this->dbh); |
71 | | $this->affected_rows = mysql_affected_rows($this->dbh); |
| 70 | $this->insert_id = mysqli_insert_id($this->dbh); |
| 71 | $this->affected_rows = mysqli_affected_rows($this->dbh); |
72 | 72 | } |
73 | 73 | else { |
74 | | $this->num_rows = mysql_num_rows($this->sh); |
| 74 | $this->num_rows = mysqli_num_rows($this->sh); |
75 | 75 | } |
76 | 76 | |
77 | 77 | if ($this->sh === false) { |
78 | 78 | if ($this->db->fatal_errors) |
79 | | trigger_error('SQL Error: '.mysql_error($this->dbh).' [#'.mysql_errno($this->dbh).']', E_USER_ERROR); |
| 79 | trigger_error('SQL Error: '.mysqli_error($this->dbh).' [#'.mysqli_errno($this->dbh).']', E_USER_ERROR); |
80 | 80 | else |
81 | 81 | $this->db->error(); |
82 | 82 | } |
… |
… |
class Database_Query_mysql extends Database_Query { |
87 | 87 | * php. The only difference is that the resource handle gets passed-in |
88 | 88 | * automatically. eg. |
89 | 89 | * |
90 | | * mysql_fetch_row($result); -> $sh->fetch_row(); |
91 | | * mysql_affected_rows($dbh); -> $sh->affected_rows(); |
| 90 | * mysqli_fetch_row($result); -> $sh->fetch_row(); |
| 91 | * mysqli_affected_rows($dbh); -> $sh->affected_rows(); |
92 | 92 | **/ |
93 | 93 | |
94 | 94 | /** |
… |
… |
class Database_Query_mysql extends Database_Query { |
96 | 96 | * @return mixed |
97 | 97 | **/ |
98 | 98 | function fetch_col() { |
99 | | list($return) = mysql_fetch_row($this->sh); |
| 99 | list($return) = mysqli_fetch_row($this->sh); |
100 | 100 | return $return; |
101 | 101 | } |
102 | 102 | |
… |
… |
class Database_Query_mysql extends Database_Query { |
114 | 114 | * @return array |
115 | 115 | **/ |
116 | 116 | function fetch_row() { |
117 | | return mysql_fetch_row($this->sh); |
| 117 | return mysqli_fetch_row($this->sh); |
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
… |
… |
class Database_Query_mysql extends Database_Query { |
124 | 124 | * @return assoc |
125 | 125 | **/ |
126 | 126 | function fetch_assoc() { |
127 | | return mysql_fetch_assoc($this->sh); |
| 127 | return mysqli_fetch_assoc($this->sh); |
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
… |
… |
class Database_Query_mysql extends Database_Query { |
134 | 134 | * @return assoc |
135 | 135 | **/ |
136 | 136 | function fetch_array($result_type=MYSQL_BOTH) { |
137 | | return mysql_fetch_array($this->sh, $result_type); |
| 137 | return mysqli_fetch_array($this->sh, $result_type); |
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
… |
… |
class Database_Query_mysql extends Database_Query { |
144 | 144 | * @return object |
145 | 145 | **/ |
146 | 146 | function fetch_object() { |
147 | | return mysql_fetch_object($this->sh); |
| 147 | return mysqli_fetch_object($this->sh); |
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
… |
… |
class Database_Query_mysql extends Database_Query { |
152 | 152 | * @return bool |
153 | 153 | **/ |
154 | 154 | function data_seek($row_number) { |
155 | | return mysql_data_seek($this->sh, $row_number); |
| 155 | return mysqli_data_seek($this->sh, $row_number); |
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
… |
… |
class Database_Query_mysql extends Database_Query { |
184 | 184 | **/ |
185 | 185 | function finish() { |
186 | 186 | if ($this->sh && is_resource($this->sh)) |
187 | | mysql_free_result($this->sh); |
| 187 | mysqli_free_result($this->sh); |
188 | 188 | unset($this->sh); |
189 | 189 | } |
190 | 190 | |
diff --git a/classes/Database/mysql.php b/classes/Database/mysql.php
index 6baa795..e0d563f 100644
a
|
b
|
class Database_mysql extends Database { |
52 | 52 | } |
53 | 53 | } |
54 | 54 | // Connect to the database |
55 | | $this->dbh = @mysql_connect($port ? "$server:$port" : $server, $login, $password) |
| 55 | $this->dbh = @mysqli_connect($port ? "$server:$port" : $server, $login, $password) |
56 | 56 | or $this->error("Can't connect to the database server."); |
57 | 57 | if ($this->dbh) { |
58 | | @mysql_select_db($db_name, $this->dbh) |
| 58 | @mysqli_select_db($db_name, $this->dbh) |
59 | 59 | or $this->error("Can't access the database file."); |
60 | 60 | } |
61 | 61 | } |
… |
… |
class Database_mysql extends Database { |
73 | 73 | if (is_null($string)) |
74 | 74 | return 'NULL'; |
75 | 75 | // Just a string |
76 | | return str_replace('?', '\\?', "'".mysql_real_escape_string($string, $this->dbh)."'"); |
| 76 | return str_replace('?', '\\?', "'".mysqli_real_escape_string($string, $this->dbh)."'"); |
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
… |
… |
class Database_mysql extends Database { |
110 | 110 | * @return string The most recent error string |
111 | 111 | **/ |
112 | 112 | function _errstr() { |
113 | | return $this->dbh ? mysql_error($this->dbh) : mysql_error(); |
| 113 | return $this->dbh ? mysqli_error($this->dbh) : mysqli_error(); |
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
117 | 117 | * @return int The most recent error number |
118 | 118 | **/ |
119 | 119 | function _errno() { |
120 | | return $this->dbh ? mysql_errno($this->dbh) : mysql_errno(); |
| 120 | return $this->dbh ? mysqli_errno($this->dbh) : mysqli_errno(); |
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
124 | 124 | * @return string Information about the mysql server |
125 | 125 | **/ |
126 | 126 | function server_info() { |
127 | | return mysql_get_server_info($this->dbh); |
| 127 | return mysqli_get_server_info($this->dbh); |
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
131 | 131 | * @return bool true on success |
132 | 132 | **/ |
133 | 133 | function close() { |
134 | | return mysql_close($this->dbh); |
| 134 | return mysqli_close($this->dbh); |
135 | 135 | } |
136 | 136 | |
137 | 137 | } |
diff --git a/classes/vcalendar.php b/classes/vcalendar.php
index 86b7db3..a1b2a7c 100644
a
|
b
|
class vcalendar { |
84 | 84 | * @since 2.2.13 - 2007-12-30 |
85 | 85 | * @return void |
86 | 86 | */ |
87 | | function vcalendar () { |
| 87 | function __construct () { |
88 | 88 | $this->_makeVersion(); |
89 | 89 | $this->calscale = null; |
90 | 90 | $this->method = null; |
… |
… |
class vcalendar { |
107 | 107 | $this->components = array(); |
108 | 108 | $this->setProperty( 'X-WR-TIMEZONE', date('e') ); |
109 | 109 | } |
| 110 | function vcalendar () { |
| 111 | self::__construct(); |
| 112 | } |
110 | 113 | /*********************************************************************************/ |
111 | 114 | /** |
112 | 115 | * Property Name: CALSCALE |
… |
… |
class calendarComponent { |
1792 | 1795 | * @author Kjell-Inge Gustafsson <ical@kigkonsult.se> |
1793 | 1796 | * @since 2.3.1 - 2007-11-19 |
1794 | 1797 | */ |
1795 | | function calendarComponent() { |
| 1798 | function __construct () { |
1796 | 1799 | $this->objName = ( isset( $this->timezonetype )) ? |
1797 | 1800 | strtolower( $this->timezonetype ) : get_class ( $this ); |
1798 | 1801 | $this->uid = array(); |
… |
… |
class calendarComponent { |
1851 | 1854 | |
1852 | 1855 | $this->_makeDtstamp(); |
1853 | 1856 | } |
| 1857 | function calendarComponent() { |
| 1858 | self::__construct(); |
| 1859 | } |
1854 | 1860 | /*********************************************************************************/ |
1855 | 1861 | /** |
1856 | 1862 | * Property Name: ACTION |
… |
… |
class vevent extends calendarComponent { |
7027 | 7033 | * @since 0.3.0 - 2006-08-10 |
7028 | 7034 | * @return void |
7029 | 7035 | */ |
7030 | | function vevent() { |
| 7036 | function __construct() { |
7031 | 7037 | $this->calendarComponent(); |
7032 | 7038 | } |
| 7039 | function vevent() { |
| 7040 | self::__construct(); |
| 7041 | } |
7033 | 7042 | /** |
7034 | 7043 | * create formatted output for calendar component VEVENT object instance |
7035 | 7044 | * |
… |
… |
class vtodo extends calendarComponent { |
7100 | 7109 | * @since 0.3.0 - 2006-08-10 |
7101 | 7110 | * @return void |
7102 | 7111 | */ |
7103 | | function vtodo() { |
| 7112 | function __construct() { |
7104 | 7113 | $this->calendarComponent(); |
7105 | 7114 | } |
| 7115 | function vtodo() { |
| 7116 | self::__construct(); |
| 7117 | } |
7106 | 7118 | /** |
7107 | 7119 | * create formatted output for calendar component VTODO object instance |
7108 | 7120 | * |
… |
… |
class vjournal extends calendarComponent { |
7174 | 7186 | * @since 0.3.0 - 2006-08-10 |
7175 | 7187 | * @return void |
7176 | 7188 | */ |
7177 | | function vjournal() { |
| 7189 | function __construct() { |
7178 | 7190 | $this->calendarComponent(); |
7179 | 7191 | } |
| 7192 | function vjournal() { |
| 7193 | self::__construct(); |
| 7194 | } |
7180 | 7195 | /** |
7181 | 7196 | * create formatted output for calendar component VJOURNAL object instance |
7182 | 7197 | * |
… |
… |
class vfreebusy extends calendarComponent { |
7237 | 7252 | * @since 0.7.3 - 2006-09-09 |
7238 | 7253 | * @return void |
7239 | 7254 | */ |
7240 | | function vfreebusy() { |
| 7255 | function __construct() { |
7241 | 7256 | $this->calendarComponent(); |
7242 | 7257 | } |
| 7258 | function vfreebusy() { |
| 7259 | self::__construct(); |
| 7260 | } |
7243 | 7261 | /** |
7244 | 7262 | * create formatted output for calendar component VFREEBUSY object instance |
7245 | 7263 | * |
… |
… |
class valarm extends calendarComponent { |
7288 | 7306 | * @since 0.3.0 - 2006-08-10 |
7289 | 7307 | * @return void |
7290 | 7308 | */ |
7291 | | function valarm() { |
| 7309 | function __construct() { |
7292 | 7310 | $this->calendarComponent(); |
7293 | 7311 | } |
| 7312 | function valarm() { |
| 7313 | self::__construct(); |
| 7314 | } |
7294 | 7315 | /** |
7295 | 7316 | * create formatted output for calendar component VALARM object instance |
7296 | 7317 | * |
… |
… |
class vtimezone extends calendarComponent { |
7337 | 7358 | * @param string $timezonetype optional, default FALSE ( STANDARD / DAYLIGHT ) |
7338 | 7359 | * @return void |
7339 | 7360 | */ |
7340 | | function vtimezone( $timezonetype=FALSE ) { |
| 7361 | function __construct( $timezonetype=FALSE ) { |
7341 | 7362 | if( !$timezonetype ) |
7342 | 7363 | $this->timezonetype = 'VTIMEZONE'; |
7343 | 7364 | else |
7344 | 7365 | $this->timezonetype = strtoupper( $timezonetype ); |
7345 | 7366 | $this->calendarComponent(); |
7346 | 7367 | } |
| 7368 | function vtimezone($timezonetype=FALSE) { |
| 7369 | self::__construct($timezonetype=FALSE); |
| 7370 | } |
7347 | 7371 | /** |
7348 | 7372 | * create formatted output for calendar component VTIMEZONE object instance |
7349 | 7373 | * |
diff --git a/includes/sorting.php b/includes/sorting.php
index 54ceb0b..e307525 100644
a
|
b
|
|
86 | 86 | // This sortby method is the first element in the sort array, let's reverse it (unless told otherwise) |
87 | 87 | if ($_SESSION[$session][0]['field'] == $_GET['sortby']) { |
88 | 88 | if (isset($_GET['reverse'])) |
89 | | $_SESSION[$session][0]['reverse'] = ($_GET['reverse'] > 0 || eregi('^y', $_GET['reverse'])) ? true : false; |
| 89 | $_SESSION[$session][0]['reverse'] = ($_GET['reverse'] > 0 || preg_match('/^y/i', $_GET['reverse'])) ? true : false; |
90 | 90 | else |
91 | 91 | $_SESSION[$session][0]['reverse'] = $_SESSION[$session][0]['reverse'] ? false : true; |
92 | 92 | } |
diff --git a/modules/music/mp3act_functions.php b/modules/music/mp3act_functions.php
index b6fc7e0..259d29d 100644
a
|
b
|
function musicLookup($type, $itemid) |
835 | 835 | 'GROUP BY ms.album_id '. |
836 | 836 | 'ORDER BY playcount DESC '. |
837 | 837 | 'LIMIT 40'; |
838 | | $result = mysql_query($query); |
| 838 | $result = mysqli_query($query); |
839 | 839 | if (!$result) |
840 | 840 | break; |
841 | 841 | |
… |
… |
function musicLookup($type, $itemid) |
846 | 846 | title="'.t('Return to Statistics Page').'">'.t('Back').'</a></div> |
847 | 847 | <h2 class="music">'.t('Top Played Albums').'</h2></div> |
848 | 848 | <ul class="music">'; |
849 | | while ($row = mysql_fetch_array($result)) |
| 849 | while ($row = mysqli_fetch_array($result)) |
850 | 850 | { |
851 | 851 | $output .= getHtmlAlbum($row['album_id'], $row['album_name'], |
852 | 852 | $row['artist_name'], '', '', '', $row['playcount']."x"); |
853 | 853 | } |
854 | | mysql_free_result($result); |
| 854 | mysqli_free_result($result); |
855 | 855 | $output .= '</ul>'; |
856 | 856 | break; |
857 | 857 | |
… |
… |
function musicLookup($type, $itemid) |
864 | 864 | 'GROUP BY ms.artist_id '. |
865 | 865 | 'ORDER BY playcount DESC '. |
866 | 866 | 'LIMIT 40'; |
867 | | $result = mysql_query($query); |
| 867 | $result = mysqli_query($query); |
868 | 868 | if (!$result) |
869 | 869 | break; |
870 | 870 | |
… |
… |
function musicLookup($type, $itemid) |
875 | 875 | title="'.t('Return to Statistics Page').'">'.t('Back').'</a></div> |
876 | 876 | <h2 class="music">'.t('Top Played Artist').'</h2></div> |
877 | 877 | <ul class="music">'; |
878 | | while ($row = mysql_fetch_array($result)) |
| 878 | while ($row = mysqli_fetch_array($result)) |
879 | 879 | { |
880 | 880 | $output .= getHtmlArtist($row['artist_id'], $row['artist_name'], |
881 | 881 | '', '', '', $row['playcount']."x"); |
882 | 882 | } |
883 | | mysql_free_result($result); |
| 883 | mysqli_free_result($result); |
884 | 884 | $output .= '</ul>'; |
885 | 885 | break; |
886 | 886 | |
… |
… |
function musicLookup($type, $itemid) |
919 | 919 | 'GROUP BY ms.album_id '. |
920 | 920 | 'ORDER BY ms.lastplay DESC '. |
921 | 921 | 'LIMIT 40'; |
922 | | $result = mysql_query($query); |
| 922 | $result = mysqli_query($query); |
923 | 923 | if (!$result) |
924 | 924 | break; |
925 | 925 | |
… |
… |
function musicLookup($type, $itemid) |
930 | 930 | title="'.t('Return to Statistics Page').'">'.t('Back').'</a></div> |
931 | 931 | <h2 class="music">'.t('Recently Played Albums').'</h2></div> |
932 | 932 | <ul class="music">'; |
933 | | while ($row = mysql_fetch_array($result)) |
| 933 | while ($row = mysqli_fetch_array($result)) |
934 | 934 | { |
935 | 935 | $output .= getHtmlAlbum($row['album_id'], $row['album_name'], |
936 | 936 | $row['artist_name'], '', '', '', date('m.d.Y', $row['playdate'])); |
937 | 937 | } |
938 | | mysql_free_result($result); |
| 938 | mysqli_free_result($result); |
939 | 939 | $output .= '</ul>'; |
940 | 940 | break; |
941 | 941 | |
diff --git a/modules/mythweb/tmpl/default/set_flvplayer.php b/modules/mythweb/tmpl/default/set_flvplayer.php
index 4e0b565..f6b9ac0 100644
a
|
b
|
|
23 | 23 | title="<?php echo t('Enable Flash Video player for recordings.') ?>" |
24 | 24 | <?php |
25 | 25 | $ffmpeg = ''; |
26 | | foreach (split (':', getenv ('PATH').':/usr/local/bin:/usr/bin') as $path) { |
| 26 | foreach (preg_split ('/:/', getenv ('PATH').':/usr/local/bin:/usr/bin') as $path) { |
27 | 27 | if (file_exists ($path."/ffmpeg")) { |
28 | 28 | $ffmpeg = $path."/ffmpeg"; |
29 | 29 | break; |
diff --git a/modules/tv/classes/Recording.php b/modules/tv/classes/Recording.php
index c8bc683..9d5608b 100644
a
|
b
|
class Recording { |
56 | 56 | |
57 | 57 | var $css_class; // css class, based on category and/or category_type |
58 | 58 | |
59 | | function Recording($recording_data) { |
| 59 | function __construct($recording_data) { |
60 | 60 | |
61 | 61 | // SQL data |
62 | 62 | if (is_array($recording_data) && isset($recording_data['recordid'])) { |
… |
… |
class Recording { |
124 | 124 | if ($this->chanid != '') |
125 | 125 | $this->css_class = category_class($this); |
126 | 126 | } |
| 127 | function Recording($recording_data) { |
| 128 | self::__construct($recording_data); |
| 129 | } |
127 | 130 | |
128 | 131 | } |