[ticket/572] Use json_decode/encode instead of serializing data
B3P-572
This commit is contained in:
@@ -265,7 +265,7 @@ class calendar extends module_base
|
||||
* Let's start displaying the events
|
||||
* make sure we only display events in the future
|
||||
*/
|
||||
$events = $this->utf_unserialize($portal_config['board3_calendar_events_' . $module_id]);
|
||||
$events = json_decode($portal_config['board3_calendar_events_' . $module_id], true);
|
||||
|
||||
if (!empty($events) && $this->config['board3_display_events_' . $module_id])
|
||||
{
|
||||
@@ -423,7 +423,7 @@ class calendar extends module_base
|
||||
$link_id = $this->request->variable('id', 99999999); // 0 will trigger unwanted behavior, therefore we set a number we should never reach
|
||||
$portal_config = obtain_portal_config();
|
||||
|
||||
$events = (strlen($portal_config['board3_calendar_events_' . $module_id]) >= 1) ? $this->utf_unserialize($portal_config['board3_calendar_events_' . $module_id]) : array();
|
||||
$events = (strlen($portal_config['board3_calendar_events_' . $module_id]) >= 1) ? json_decode($portal_config['board3_calendar_events_' . $module_id], true) : array();
|
||||
|
||||
// append_sid() adds adm/ already, no need to add it here
|
||||
$u_action = append_sid('index.' . $this->php_ext, 'i=\board3\portal\acp\portal_module&mode=config&module_id=' . $module_id);
|
||||
@@ -533,7 +533,7 @@ class calendar extends module_base
|
||||
$time_ary[$key] = $cur_event['start_time'];
|
||||
}
|
||||
array_multisort($time_ary, SORT_NUMERIC, $events);
|
||||
$board3_events_array = serialize($events);
|
||||
$board3_events_array = json_encode($events);
|
||||
set_portal_config('board3_calendar_events_' . $module_id, $board3_events_array);
|
||||
|
||||
trigger_error($message . adm_back_link($u_action));
|
||||
@@ -555,7 +555,7 @@ class calendar extends module_base
|
||||
array_splice($events, $link_id, 1);
|
||||
$events = array_merge($events);
|
||||
|
||||
$board3_events_array = serialize($events);
|
||||
$board3_events_array = json_encode($events);
|
||||
set_portal_config('board3_calendar_events_' . $module_id, $board3_events_array);
|
||||
|
||||
$this->log->add('admin', $this->user->data['user_id'], $this->user->data['user_ip'], 'LOG_PORTAL_EVENT_REMOVED', false, array($cur_event_title));
|
||||
@@ -711,21 +711,6 @@ class calendar extends module_base
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unserialize links array
|
||||
*
|
||||
* @param string $serial_str Serialized string
|
||||
*
|
||||
* @return array Unserialized string
|
||||
*/
|
||||
private function utf_unserialize($serial_str)
|
||||
{
|
||||
$out = preg_replace_callback('!s:(\d+):"(.*?)";!s', function ($result) {
|
||||
return 's:' . strlen($result[2]) . ":\"{$result[2]}\";";
|
||||
}, $serial_str);
|
||||
return unserialize($out);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate URLs and execute apppend_sid if necessary
|
||||
*
|
||||
|
||||
@@ -111,7 +111,7 @@ class links extends module_base
|
||||
{
|
||||
$portal_config = obtain_portal_config();
|
||||
|
||||
$links = $this->utf_unserialize($portal_config['board3_links_array_' . $module_id]);
|
||||
$links = json_decode($portal_config['board3_links_array_' . $module_id], true);
|
||||
|
||||
// get user's groups
|
||||
$groups_ary = get_user_groups();
|
||||
@@ -200,7 +200,7 @@ class links extends module_base
|
||||
);
|
||||
}
|
||||
|
||||
$board3_menu_array = serialize($links);
|
||||
$board3_menu_array = json_encode($links);
|
||||
set_portal_config('board3_links_array_' . $module_id, $board3_menu_array);
|
||||
$this->config->set('board3_links_' . $module_id, '');
|
||||
$this->config->set('board3_links_url_new_window_' . $module_id, 0);
|
||||
@@ -247,7 +247,7 @@ class links extends module_base
|
||||
$link_id = $this->request->variable('id', 99999999); // 0 will trigger unwanted behavior, therefore we set a number we should never reach
|
||||
$portal_config = obtain_portal_config();
|
||||
|
||||
$links = $this->utf_unserialize($portal_config['board3_links_array_' . $module_id]);
|
||||
$links = json_decode($portal_config['board3_links_array_' . $module_id], true);
|
||||
|
||||
$u_action = append_sid('index.' . $this->php_ext, 'i=\board3\portal\acp\portal_module&mode=config&module_id=' . $module_id);
|
||||
|
||||
@@ -319,7 +319,7 @@ class links extends module_base
|
||||
$this->log->add('admin', $this->user->data['user_id'], $this->user->data['user_ip'],'LOG_PORTAL_LINK_ADDED', false, array($link_title));
|
||||
}
|
||||
|
||||
$board3_links_array = serialize($links);
|
||||
$board3_links_array = json_encode($links);
|
||||
set_portal_config('board3_links_array_' . $module_id, $board3_links_array);
|
||||
|
||||
trigger_error($message . adm_back_link($u_action));
|
||||
@@ -341,7 +341,7 @@ class links extends module_base
|
||||
array_splice($links, $link_id, 1);
|
||||
$links = array_merge($links);
|
||||
|
||||
$board3_links_array = serialize($links);
|
||||
$board3_links_array = json_encode($links);
|
||||
set_portal_config('board3_links_array_' . $module_id, $board3_links_array);
|
||||
|
||||
$this->log->add('admin', $this->user->data['user_id'], $this->user->data['user_ip'], 'LOG_PORTAL_LINK_REMOVED', false, array($cur_link_title));
|
||||
@@ -397,7 +397,7 @@ class links extends module_base
|
||||
// insert the info of the moved link
|
||||
$links[$switch_order_id] = $cur_link;
|
||||
|
||||
$board3_links_array = serialize($links);
|
||||
$board3_links_array = json_encode($links);
|
||||
set_portal_config('board3_links_array_' . $module_id, $board3_links_array);
|
||||
|
||||
break;
|
||||
@@ -460,19 +460,4 @@ class links extends module_base
|
||||
{
|
||||
$this->manage_links('', $key, $module_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unserialize links array
|
||||
*
|
||||
* @param string $serial_str Serialized string
|
||||
*
|
||||
* @return array Unserialized string
|
||||
*/
|
||||
private function utf_unserialize($serial_str)
|
||||
{
|
||||
$out = preg_replace_callback('!s:(\d+):"(.*?)";!s', function ($result) {
|
||||
return 's:' . strlen($result[2]) . ":\"{$result[2]}\";";
|
||||
}, $serial_str);
|
||||
return unserialize($out);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ class main_menu extends module_base
|
||||
{
|
||||
$portal_config = obtain_portal_config();
|
||||
|
||||
$links = $this->utf_unserialize($portal_config['board3_menu_array_' . $module_id]);
|
||||
$links = json_decode($portal_config['board3_menu_array_' . $module_id], true);
|
||||
|
||||
$this->template->assign_block_vars('portal_menu', array('MODULE_ID' => $module_id));
|
||||
|
||||
@@ -255,7 +255,7 @@ class main_menu extends module_base
|
||||
);
|
||||
}
|
||||
|
||||
$board3_menu_array = serialize($links);
|
||||
$board3_menu_array = json_encode($links);
|
||||
set_portal_config('board3_menu_array_' . $module_id, $board3_menu_array);
|
||||
$this->config->set('board3_menu_' . $module_id, '');
|
||||
$this->config->set('board3_menu_url_new_window_' . $module_id, 0);
|
||||
@@ -302,7 +302,7 @@ class main_menu extends module_base
|
||||
$link_id = $this->request->variable('id', 99999999); // 0 will trigger unwanted behavior, therefore we set a number we should never reach
|
||||
$portal_config = obtain_portal_config();
|
||||
|
||||
$links = $this->utf_unserialize($portal_config['board3_menu_array_' . $module_id]);
|
||||
$links = json_decode($portal_config['board3_menu_array_' . $module_id], true);
|
||||
|
||||
$u_action = append_sid('index.' . $this->php_ext, 'i=%5Cboard3%5Cportal%5Cacp%5Cportal_module&mode=config&module_id=' . $module_id);
|
||||
|
||||
@@ -379,7 +379,7 @@ class main_menu extends module_base
|
||||
$this->log->add('admin', $this->user->data['user_id'], $this->user->data['user_ip'], 'LOG_PORTAL_LINK_ADDED', false, array($link_title));
|
||||
}
|
||||
|
||||
$board3_menu_array = serialize($links);
|
||||
$board3_menu_array = json_encode($links);
|
||||
set_portal_config('board3_menu_array_' . $module_id, $board3_menu_array);
|
||||
|
||||
trigger_error($message . adm_back_link($u_action));
|
||||
@@ -401,7 +401,7 @@ class main_menu extends module_base
|
||||
array_splice($links, $link_id, 1);
|
||||
$links = array_merge($links);
|
||||
|
||||
$board3_menu_array = serialize($links);
|
||||
$board3_menu_array = json_encode($links);
|
||||
set_portal_config('board3_menu_array_' . $module_id, $board3_menu_array);
|
||||
|
||||
$this->log->add('admin', $this->user->data['user_id'], $this->user->data['user_ip'], 'LOG_PORTAL_LINK_REMOVED', false, array($cur_link_title));
|
||||
@@ -457,7 +457,7 @@ class main_menu extends module_base
|
||||
// insert the info of the moved link
|
||||
$links[$switch_order_id] = $cur_link;
|
||||
|
||||
$board3_menu_array = serialize($links);
|
||||
$board3_menu_array = json_encode($links);
|
||||
set_portal_config('board3_menu_array_' . $module_id, $board3_menu_array);
|
||||
|
||||
break;
|
||||
@@ -524,19 +524,4 @@ class main_menu extends module_base
|
||||
{
|
||||
$this->manage_links('', $key, $module_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unserialize links array
|
||||
*
|
||||
* @param string $serial_str Serialized string
|
||||
*
|
||||
* @return array Unserialized string
|
||||
*/
|
||||
private function utf_unserialize($serial_str)
|
||||
{
|
||||
$out = preg_replace_callback('!s:(\d+):"(.*?)";!s', function ($result) {
|
||||
return 's:' . strlen($result[2]) . ":\"{$result[2]}\";";
|
||||
}, $serial_str);
|
||||
return unserialize($out);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user