Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/wordfenc.../lib
File: wfNotification.php
<?php
[0] Fix | Delete
class wfNotification {
[1] Fix | Delete
const PRIORITY_LOW = 1500;
[2] Fix | Delete
const PRIORITY_DEFAULT = 1000;
[3] Fix | Delete
const PRIORITY_HIGH = 500;
[4] Fix | Delete
const PRIORITY_HIGH_CRITICAL = 501;
[5] Fix | Delete
const PRIORITY_HIGH_WARNING = 502;
[6] Fix | Delete
[7] Fix | Delete
protected $_id;
[8] Fix | Delete
protected $_category;
[9] Fix | Delete
protected $_priority;
[10] Fix | Delete
protected $_ctime;
[11] Fix | Delete
protected $_html;
[12] Fix | Delete
protected $_links;
[13] Fix | Delete
[14] Fix | Delete
public static function notifications($since = 0) {
[15] Fix | Delete
global $wpdb;
[16] Fix | Delete
$table_wfNotifications = wfDB::networkTable('wfNotifications');
[17] Fix | Delete
$rawNotifications = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$table_wfNotifications} WHERE `new` = 1 AND `ctime` > %d ORDER BY `priority` ASC, `ctime` DESC", $since), ARRAY_A);
[18] Fix | Delete
$notifications = array();
[19] Fix | Delete
foreach ($rawNotifications as $raw) {
[20] Fix | Delete
$notifications[] = new wfNotification($raw['id'], $raw['priority'], $raw['html'], $raw['category'], $raw['ctime'], json_decode($raw['links'], true), true);
[21] Fix | Delete
}
[22] Fix | Delete
return $notifications;
[23] Fix | Delete
}
[24] Fix | Delete
[25] Fix | Delete
public static function getNotificationForID($id) {
[26] Fix | Delete
global $wpdb;
[27] Fix | Delete
$table_wfNotifications = wfDB::networkTable('wfNotifications');
[28] Fix | Delete
$rawNotifications = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$table_wfNotifications} WHERE `id` = %s ORDER BY `priority` ASC, `ctime` DESC", $id), ARRAY_A);
[29] Fix | Delete
if (count($rawNotifications) == 1) {
[30] Fix | Delete
$raw = $rawNotifications[0];
[31] Fix | Delete
return new wfNotification($raw['id'], $raw['priority'], $raw['html'], $raw['category'], $raw['ctime'], json_decode($raw['links'], true), true);
[32] Fix | Delete
}
[33] Fix | Delete
return null;
[34] Fix | Delete
}
[35] Fix | Delete
[36] Fix | Delete
public static function getNotificationForCategory($category, $requireNew = true) {
[37] Fix | Delete
global $wpdb;
[38] Fix | Delete
$table_wfNotifications = wfDB::networkTable('wfNotifications');
[39] Fix | Delete
$rawNotifications = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$table_wfNotifications} WHERE " . ($requireNew ? '`new` = 1 AND ' : '') . "`category` = %s ORDER BY `priority` ASC, `ctime` DESC LIMIT 1", $category), ARRAY_A);
[40] Fix | Delete
if (count($rawNotifications) == 1) {
[41] Fix | Delete
$raw = $rawNotifications[0];
[42] Fix | Delete
return new wfNotification($raw['id'], $raw['priority'], $raw['html'], $raw['category'], $raw['ctime'], json_decode($raw['links'], true), true);
[43] Fix | Delete
}
[44] Fix | Delete
return null;
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
public static function reconcileNotificationsWithOptions() {
[48] Fix | Delete
$notification_updatesNeeded = wfConfig::get('notification_updatesNeeded');
[49] Fix | Delete
$notification_securityAlerts = wfConfig::get('notification_securityAlerts') || !wfConfig::p();
[50] Fix | Delete
$notification_promotions = wfConfig::get('notification_promotions') || !wfConfig::p();
[51] Fix | Delete
$notification_blogHighlights = wfConfig::get('notification_blogHighlights') || !wfConfig::p();
[52] Fix | Delete
$notification_productUpdates = wfConfig::get('notification_productUpdates') || !wfConfig::p();
[53] Fix | Delete
$notification_scanStatus = wfConfig::get('notification_scanStatus');
[54] Fix | Delete
[55] Fix | Delete
$notifications = self::notifications();
[56] Fix | Delete
foreach ($notifications as $n) {
[57] Fix | Delete
$category = $n->category;
[58] Fix | Delete
[59] Fix | Delete
if (preg_match('/^release/i', $category) && !$notification_productUpdates) { $n->markAsRead(); }
[60] Fix | Delete
if (preg_match('/^digest/i', $category) && !$notification_blogHighlights) { $n->markAsRead(); }
[61] Fix | Delete
if (preg_match('/^alert/i', $category) && !$notification_securityAlerts) { $n->markAsRead(); }
[62] Fix | Delete
if (preg_match('/^promo/i', $category) && !$notification_promotions) { $n->markAsRead(); }
[63] Fix | Delete
[64] Fix | Delete
switch ($category) {
[65] Fix | Delete
case 'wfplugin_scan':
[66] Fix | Delete
if (!$notification_scanStatus) { $n->markAsRead(); }
[67] Fix | Delete
break;
[68] Fix | Delete
case 'wfplugin_updates':
[69] Fix | Delete
if (!$notification_updatesNeeded) { $n->markAsRead(); }
[70] Fix | Delete
break;
[71] Fix | Delete
case 'wfplugin_keyconflict':
[72] Fix | Delete
default:
[73] Fix | Delete
//Allow it
[74] Fix | Delete
break;
[75] Fix | Delete
}
[76] Fix | Delete
}
[77] Fix | Delete
}
[78] Fix | Delete
[79] Fix | Delete
public function __construct($id, $priority, $html, $category = null, $ctime = null, $links = null, $memoryOnly = false) {
[80] Fix | Delete
if ($id === null) {
[81] Fix | Delete
$id = 'site-' . wfUtils::base32_encode(pack('I', wfConfig::atomicInc('lastNotificationID')));
[82] Fix | Delete
}
[83] Fix | Delete
[84] Fix | Delete
if ($category === null) {
[85] Fix | Delete
$category = '';
[86] Fix | Delete
}
[87] Fix | Delete
[88] Fix | Delete
if ($ctime === null) {
[89] Fix | Delete
$ctime = time();
[90] Fix | Delete
}
[91] Fix | Delete
[92] Fix | Delete
if (!is_array($links)) {
[93] Fix | Delete
$links = array();
[94] Fix | Delete
}
[95] Fix | Delete
[96] Fix | Delete
$this->_id = $id;
[97] Fix | Delete
$this->_category = $category;
[98] Fix | Delete
$this->_priority = $priority;
[99] Fix | Delete
$this->_ctime = $ctime;
[100] Fix | Delete
$this->_html = $html;
[101] Fix | Delete
$this->_links = $links;
[102] Fix | Delete
[103] Fix | Delete
global $wpdb;
[104] Fix | Delete
if (!$memoryOnly) {
[105] Fix | Delete
$linksJSON = json_encode($links);
[106] Fix | Delete
[107] Fix | Delete
$notification_updatesNeeded = wfConfig::get('notification_updatesNeeded');
[108] Fix | Delete
$notification_securityAlerts = wfConfig::get('notification_securityAlerts') || !wfConfig::p();
[109] Fix | Delete
$notification_promotions = wfConfig::get('notification_promotions') || !wfConfig::p();
[110] Fix | Delete
$notification_blogHighlights = wfConfig::get('notification_blogHighlights') || !wfConfig::p();
[111] Fix | Delete
$notification_productUpdates = wfConfig::get('notification_productUpdates') || !wfConfig::p();
[112] Fix | Delete
$notification_scanStatus = wfConfig::get('notification_scanStatus');
[113] Fix | Delete
[114] Fix | Delete
if (preg_match('/^release/i', $category) && !$notification_productUpdates) { return; }
[115] Fix | Delete
if (preg_match('/^digest/i', $category) && !$notification_blogHighlights) { return; }
[116] Fix | Delete
if (preg_match('/^alert/i', $category) && !$notification_securityAlerts) { return; }
[117] Fix | Delete
if (preg_match('/^promo/i', $category) && !$notification_promotions) { return; }
[118] Fix | Delete
[119] Fix | Delete
switch ($category) {
[120] Fix | Delete
case 'wfplugin_scan':
[121] Fix | Delete
if (!$notification_scanStatus) { return; }
[122] Fix | Delete
break;
[123] Fix | Delete
case 'wfplugin_updates':
[124] Fix | Delete
if (!$notification_updatesNeeded) { return; }
[125] Fix | Delete
break;
[126] Fix | Delete
case 'wfplugin_keyconflict':
[127] Fix | Delete
default:
[128] Fix | Delete
//Allow it
[129] Fix | Delete
break;
[130] Fix | Delete
}
[131] Fix | Delete
[132] Fix | Delete
$table_wfNotifications = wfDB::networkTable('wfNotifications');
[133] Fix | Delete
if (!empty($category)) {
[134] Fix | Delete
$existing = self::getNotificationForCategory($category);
[135] Fix | Delete
if ($existing) {
[136] Fix | Delete
$wpdb->query($wpdb->prepare("UPDATE {$table_wfNotifications} SET priority = %d, ctime = %d, html = %s, links = %s WHERE id = %s", $priority, $ctime, $html, $linksJSON, $existing->id));
[137] Fix | Delete
return;
[138] Fix | Delete
}
[139] Fix | Delete
}
[140] Fix | Delete
[141] Fix | Delete
$wpdb->query($wpdb->prepare("INSERT IGNORE INTO {$table_wfNotifications} (id, category, priority, ctime, html, links) VALUES (%s, %s, %d, %d, %s, %s)", $id, $category, $priority, $ctime, $html, $linksJSON));
[142] Fix | Delete
}
[143] Fix | Delete
}
[144] Fix | Delete
[145] Fix | Delete
public function __get($key){
[146] Fix | Delete
if ($key == 'id') { return $this->_id; }
[147] Fix | Delete
else if ($key == 'category') { return $this->_category; }
[148] Fix | Delete
else if ($key == 'priority') { return $this->_priority; }
[149] Fix | Delete
else if ($key == 'ctime') { return $this->_ctime; }
[150] Fix | Delete
else if ($key == 'html') { return $this->_html; }
[151] Fix | Delete
else if ($key == 'links') { return $this->_links; }
[152] Fix | Delete
throw new InvalidArgumentException();
[153] Fix | Delete
}
[154] Fix | Delete
[155] Fix | Delete
public function markAsRead() {
[156] Fix | Delete
global $wpdb;
[157] Fix | Delete
$table_wfNotifications = wfDB::networkTable('wfNotifications');
[158] Fix | Delete
$wpdb->query($wpdb->prepare("UPDATE {$table_wfNotifications} SET `new` = 0 WHERE `id` = %s", $this->_id));
[159] Fix | Delete
}
[160] Fix | Delete
}
[161] Fix | Delete
[162] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function