fix php 8 deprecated function, clean code
parent
0ae0ca03d1
commit
234a496ac4
|
@ -12,7 +12,6 @@
|
|||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -72,6 +71,7 @@ class zoneclearFeedServer
|
|||
if ($id < 1) {
|
||||
throw new Exception(__('No such ID'));
|
||||
}
|
||||
|
||||
$cur->feed_upddt = date('Y-m-d H:i:s');
|
||||
|
||||
$cur->update(sprintf(
|
||||
|
@ -81,8 +81,7 @@ class zoneclearFeedServer
|
|||
));
|
||||
$this->con->unlock();
|
||||
$this->trigger();
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$this->con->unlock();
|
||||
throw $e;
|
||||
}
|
||||
|
@ -115,8 +114,7 @@ class zoneclearFeedServer
|
|||
$cur->insert();
|
||||
$this->con->unlock();
|
||||
$this->trigger();
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$this->con->unlock();
|
||||
throw $e;
|
||||
}
|
||||
|
@ -145,11 +143,11 @@ class zoneclearFeedServer
|
|||
if ($id < 1) {
|
||||
throw new Exception(__('No such ID'));
|
||||
}
|
||||
|
||||
$cur = $this->openCursor();
|
||||
$this->con->writeLock($this->table);
|
||||
|
||||
$cur->feed_upddt = date('Y-m-d H:i:s');
|
||||
|
||||
$cur->feed_status = (integer) $enable;
|
||||
if (null !== $time) {
|
||||
$cur->feed_upd_last = (integer) $time;
|
||||
|
@ -162,8 +160,7 @@ class zoneclearFeedServer
|
|||
));
|
||||
$this->con->unlock();
|
||||
$this->trigger();
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$this->con->unlock();
|
||||
throw $e;
|
||||
}
|
||||
|
@ -216,7 +213,6 @@ class zoneclearFeedServer
|
|||
public function getPostsByFeed($params = array(), $count_only = false)
|
||||
{
|
||||
if (!isset($params['feed_id'])) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -244,8 +240,7 @@ class zoneclearFeedServer
|
|||
{
|
||||
if ($count_only) {
|
||||
$strReq = 'SELECT count(Z.feed_id) ';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$content_req = '';
|
||||
if (!empty($params['columns']) && is_array($params['columns'])) {
|
||||
$content_req .= implode(', ', $params['columns']) . ', ';
|
||||
|
@ -275,17 +270,15 @@ class zoneclearFeedServer
|
|||
|
||||
if (isset($params['feed_type'])) {
|
||||
$strReq .= "AND Z.feed_type = '" . $this->con->escape($params['type']) . "' ";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$strReq .= "AND Z.feed_type = 'feed' ";
|
||||
}
|
||||
|
||||
if (!empty($params['feed_id'])) {
|
||||
if (is_array($params['feed_id'])) {
|
||||
array_walk($params['feed_id'],create_function('&$v,$k','if($v!==null){$v=(integer)$v;}'));
|
||||
}
|
||||
else {
|
||||
$params['feed_id'] = array((integer) $params['feed_id']);
|
||||
array_walk($params['feed_id'], function(&$v, $k) { if($v !== null) { $v = (integer) $v; }});
|
||||
} else {
|
||||
$params['feed_id'] = [(integer) $params['feed_id']];
|
||||
}
|
||||
$strReq .= 'AND Z.feed_id ' . $this->con->in($params['feed_id']);
|
||||
}
|
||||
|
@ -307,8 +300,7 @@ class zoneclearFeedServer
|
|||
if (!$count_only) {
|
||||
if (!empty($params['order'])) {
|
||||
$strReq .= 'ORDER BY ' . $this->con->escape($params['order']) . ' ';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$strReq .= 'ORDER BY Z.feed_upddt DESC ';
|
||||
}
|
||||
}
|
||||
|
@ -387,8 +379,7 @@ class zoneclearFeedServer
|
|||
$this->lock = $fp;
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
|
@ -417,8 +408,7 @@ class zoneclearFeedServer
|
|||
# Limit to one update at a time
|
||||
try {
|
||||
$this->lockUpdate();
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
if ($throw) {
|
||||
throw $e;
|
||||
}
|
||||
|
@ -432,17 +422,11 @@ class zoneclearFeedServer
|
|||
|
||||
# All feeds or only one (from admin)
|
||||
$f = !$id ?
|
||||
$this->getFeeds(array(
|
||||
'feed_status'=>1,
|
||||
'order'=>'feed_upd_last ASC'
|
||||
)) :
|
||||
$this->getFeeds(array(
|
||||
'feed_id'=>$id
|
||||
));
|
||||
$this->getFeeds(['feed_status' => 1, 'order' => 'feed_upd_last ASC']) :
|
||||
$this->getFeeds(['feed_id' => $id]);
|
||||
|
||||
# No feed
|
||||
if ($f->isEmpty()) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -450,7 +434,7 @@ class zoneclearFeedServer
|
|||
$this->enableUser($s->zoneclearFeedServer_user);
|
||||
|
||||
$updates = false;
|
||||
$loop_mem = array();
|
||||
$loop_mem = [];
|
||||
|
||||
$limit = abs((integer) $s->zoneclearFeedServer_update_limit);
|
||||
if ($limit < 1) {
|
||||
|
@ -474,23 +458,21 @@ class zoneclearFeedServer
|
|||
# Keep active empty feed or disable it ?
|
||||
if (!$s->zoneclearFeedServer_keep_empty_feed) {
|
||||
$this->enableFeed($f->feed_id, false);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
# Set update time of this feed
|
||||
$this->enableFeed($f->feed_id, true, $time);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
# Not updated since last visit
|
||||
elseif (!$id
|
||||
} elseif (!$id
|
||||
&& '' != $feed->pubdate
|
||||
&& strtotime($feed->pubdate) < $f->feed_upd_last
|
||||
) {
|
||||
# Set update time of this feed
|
||||
$this->enableFeed($f->feed_id, true, $time);
|
||||
$i++;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
# Set update time of this feed
|
||||
$this->enableFeed($f->feed_id, $f->feed_status, $time);
|
||||
|
||||
|
@ -562,7 +544,7 @@ class zoneclearFeedServer
|
|||
);
|
||||
|
||||
$post_id = $this->core->auth->sudo(
|
||||
array($this->core->blog, 'addPost'),
|
||||
[$this->core->blog, 'addPost'],
|
||||
$cur_post
|
||||
);
|
||||
|
||||
|
@ -577,9 +559,9 @@ class zoneclearFeedServer
|
|||
if ($cur_post->post_status == 1) {
|
||||
$is_new_published_entry = true;
|
||||
}
|
||||
}
|
||||
|
||||
# Update entry
|
||||
else {
|
||||
} else {
|
||||
$post_id = $old_post->post_id;
|
||||
|
||||
# --BEHAVIOR-- zoneclearFeedServerBeforePostUpdate
|
||||
|
@ -590,7 +572,7 @@ class zoneclearFeedServer
|
|||
);
|
||||
|
||||
$this->core->auth->sudo(
|
||||
array($this->core->blog, 'updPost'),
|
||||
[$this->core->blog, 'updPost'],
|
||||
$post_id,
|
||||
$cur_post
|
||||
);
|
||||
|
@ -603,7 +585,7 @@ class zoneclearFeedServer
|
|||
);
|
||||
# Delete old tags
|
||||
$this->core->auth->sudo(
|
||||
array($this->core->meta, 'delPostMeta'),
|
||||
[$this->core->meta, 'delPostMeta'],
|
||||
$post_id,
|
||||
'tag'
|
||||
);
|
||||
|
@ -661,7 +643,7 @@ class zoneclearFeedServer
|
|||
}
|
||||
$tags = array_unique($tags);
|
||||
}
|
||||
$formated_tags = array();
|
||||
$formated_tags = [];
|
||||
foreach ($tags as $tag) {
|
||||
|
||||
# Change tags case
|
||||
|
@ -674,7 +656,7 @@ class zoneclearFeedServer
|
|||
if (!in_array($tag, $formated_tags)) {
|
||||
$formated_tags[] = $tag;
|
||||
$this->core->auth->sudo(
|
||||
array($this->core->meta, 'setPostMeta'),
|
||||
[$this->core->meta, 'setPostMeta'],
|
||||
$post_id,
|
||||
'tag',
|
||||
dcMeta::sanitizeMetaID($tag)
|
||||
|
@ -692,8 +674,7 @@ class zoneclearFeedServer
|
|||
$meta
|
||||
);
|
||||
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$this->con->rollback();
|
||||
$this->enableUser(false);
|
||||
$this->unlockUpdate();
|
||||
|
@ -723,9 +704,8 @@ class zoneclearFeedServer
|
|||
if (!$this->core->auth->checkUser($enable)) {
|
||||
throw new Exception('Unable to set user');
|
||||
}
|
||||
}
|
||||
# Disable
|
||||
else {
|
||||
} else {
|
||||
$this->core->auth = null;
|
||||
$this->core->auth = new dcAuth($this->core);
|
||||
}
|
||||
|
@ -747,9 +727,7 @@ class zoneclearFeedServer
|
|||
$feed_reader->setUserAgent(self::$nethttp_agent);
|
||||
|
||||
return $feed_reader->parse($f);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
|
||||
} catch (Exception $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -796,14 +774,11 @@ class zoneclearFeedServer
|
|||
if (empty($parse['scheme'])) {
|
||||
if (strpos($url, '/') === 0) {
|
||||
$url = $host . $url;
|
||||
}
|
||||
elseif (strpos($url, '#') === 0) {
|
||||
} elseif (strpos($url, '#') === 0) {
|
||||
$url = $root . $url;
|
||||
}
|
||||
elseif (preg_match('|/$|', $root)) {
|
||||
} elseif (preg_match('|/$|', $root)) {
|
||||
$url = $root . $url;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$url = dirname($root) . '/' . $url;
|
||||
}
|
||||
}
|
||||
|
@ -818,10 +793,10 @@ class zoneclearFeedServer
|
|||
*/
|
||||
public static function getAllStatus()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
__('Disabled') => '0',
|
||||
__('Enabled') => '1'
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -831,14 +806,14 @@ class zoneclearFeedServer
|
|||
*/
|
||||
public static function getAllUpdateInterval()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
__('Every hour') => 3600,
|
||||
__('Every two hours') => 7200,
|
||||
__('Two times per day') => 43200,
|
||||
__('Every day') => 86400,
|
||||
__('Every two days') => 172800,
|
||||
__('Every week') => 604800
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -848,7 +823,7 @@ class zoneclearFeedServer
|
|||
*/
|
||||
public function getAllBlogAdmins()
|
||||
{
|
||||
$admins = array();
|
||||
$admins = [];
|
||||
|
||||
# Get super admins
|
||||
$rs = $this->con->select(
|
||||
|
|
Loading…
Reference in New Issue