Skip to content

Commit

Permalink
Misc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisgraham committed May 13, 2017
1 parent 2ac544b commit accecf5
Show file tree
Hide file tree
Showing 19 changed files with 48 additions and 23 deletions.
2 changes: 1 addition & 1 deletion adminzone/pages/modules/admin_stats.php
Expand Up @@ -1333,7 +1333,7 @@ public function show_page()
$where .= ' OR ' . db_string_equal_to('the_page', '/' . $page); // Legacy compatibility
}
$ip_filter = $GLOBALS['DEV_MODE'] ? '' : (' AND ' . db_string_not_equal_to('ip', get_ip_address()));
$rows = $GLOBALS['SITE_DB']->query('SELECT DISTINCT ip FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'stats WHERE (' . $where . ')' . $ip_filter . ' ORDER BY ' . $sortable . ' ' . $sort_order, 1000/*reasonable limit*/);
$rows = $GLOBALS['SITE_DB']->query('SELECT DISTINCT ip,' . $sortable . ' FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'stats WHERE (' . $where . ')' . $ip_filter . ' ORDER BY ' . $sortable . ' ' . $sort_order, 1000/*reasonable limit*/);
shuffle($rows);
if (count($rows) < 1) {
$list_regionality = new Tempcode();
Expand Down
4 changes: 2 additions & 2 deletions cms/pages/modules/cms_blogs.php
Expand Up @@ -352,12 +352,12 @@ public function get_submitter($id)
/**
* Standard crud_module cat getter.
*
* @param AUTO_LINK $id The entry for which the cat is sought
* @param ID_TEXT $id The entry for which the cat is sought
* @return string The cat
*/
public function get_cat($id)
{
$temp = $GLOBALS['SITE_DB']->query_select_value_if_there('news', 'news_category', array('id' => $id));
$temp = $GLOBALS['SITE_DB']->query_select_value_if_there('news', 'news_category', array('id' => intval($id)));
if (is_null($temp)) {
warn_exit(do_lang_tempcode('MISSING_RESOURCE', 'news'));
}
Expand Down
4 changes: 2 additions & 2 deletions cms/pages/modules/cms_calendar.php
Expand Up @@ -833,12 +833,12 @@ public function get_submitter($id)
/**
* Standard crud_module cat getter.
*
* @param AUTO_LINK $id The entry for which the cat is sought
* @param ID_TEXT $id The entry for which the cat is sought
* @return mixed The cat
*/
public function get_cat($id)
{
$temp = $GLOBALS['SITE_DB']->query_select_value_if_there('calendar_events', 'e_type', array('id' => $id));
$temp = $GLOBALS['SITE_DB']->query_select_value_if_there('calendar_events', 'e_type', array('id' => intval($id)));
if (is_null($temp)) {
warn_exit(do_lang_tempcode('MISSING_RESOURCE', 'event'));
}
Expand Down
4 changes: 2 additions & 2 deletions cms/pages/modules/cms_catalogues.php
Expand Up @@ -626,7 +626,7 @@ public function get_submitter($id)
/**
* Standard crud_module cat getter.
*
* @param AUTO_LINK $id The entry for which the cat is sought
* @param ID_TEXT $id The entry for which the cat is sought
* @return string The cat
*/
public function get_cat_b($id)
Expand All @@ -641,7 +641,7 @@ public function get_cat_b($id)
/**
* Standard crud_module cat getter.
*
* @param AUTO_LINK $id The entry for which the cat is sought
* @param ID_TEXT $id The entry for which the cat is sought
* @return string The cat
*/
public function get_cat($id)
Expand Down
4 changes: 2 additions & 2 deletions cms/pages/modules/cms_downloads.php
Expand Up @@ -482,12 +482,12 @@ public function get_submitter($id)
/**
* Standard crud_module cat getter.
*
* @param AUTO_LINK $id The entry for which the cat is sought
* @param ID_TEXT $id The entry for which the cat is sought
* @return mixed The cat
*/
public function get_cat($id)
{
$temp = $GLOBALS['SITE_DB']->query_select_value_if_there('download_downloads', 'category_id', array('id' => $id));
$temp = $GLOBALS['SITE_DB']->query_select_value_if_there('download_downloads', 'category_id', array('id' => intval($id)));
if (is_null($temp)) {
warn_exit(do_lang_tempcode('MISSING_RESOURCE', 'download'));
}
Expand Down
8 changes: 4 additions & 4 deletions cms/pages/modules/cms_galleries.php
Expand Up @@ -1239,12 +1239,12 @@ public function get_submitter($id)
/**
* Standard crud_module cat getter.
*
* @param AUTO_LINK $id The entry for which the cat is sought
* @param ID_TEXT $id The entry for which the cat is sought
* @return mixed The cat
*/
public function get_cat($id)
{
$temp = $GLOBALS['SITE_DB']->query_select_value_if_there('images', 'cat', array('id' => $id));
$temp = $GLOBALS['SITE_DB']->query_select_value_if_there('images', 'cat', array('id' => intval($id)));
if (is_null($temp)) {
warn_exit(do_lang_tempcode('MISSING_RESOURCE', 'image'));
}
Expand Down Expand Up @@ -1830,12 +1830,12 @@ public function get_submitter($id)
/**
* Standard crud_module cat getter.
*
* @param AUTO_LINK $id The entry for which the cat is sought
* @param ID_TEXT $id The entry for which the cat is sought
* @return mixed The cat
*/
public function get_cat($id)
{
$temp = $GLOBALS['SITE_DB']->query_select_value_if_there('videos', 'cat', array('id' => $id));
$temp = $GLOBALS['SITE_DB']->query_select_value_if_there('videos', 'cat', array('id' => intval($id)));
if (is_null($temp)) {
warn_exit(do_lang_tempcode('MISSING_RESOURCE', 'video'));
}
Expand Down
6 changes: 3 additions & 3 deletions cms/pages/modules/cms_news.php
Expand Up @@ -316,7 +316,7 @@ public function get_form_fields($id = null, $main_news_category = null, $news_ca
}

if (!is_null($this->permissions_require)) {
check_edit_permission($this->permissions_require, $submitter, array($this->permissions_cat_require, is_null($this->permissions_cat_name) ? null : $this->get_cat($id), $this->permissions_cat_require_b, is_null($this->permissions_cat_name_b) ? null : $this->get_cat_b($id)), $this->privilege_page_name);
check_edit_permission($this->permissions_require, $submitter, array($this->permissions_cat_require, is_null($this->permissions_cat_name) ? null : $this->get_cat(strval($id)), $this->permissions_cat_require_b, is_null($this->permissions_cat_name_b) ? null : $this->get_cat_b(strval($id))), $this->privilege_page_name);
}

$ret = $this->fill_in_edit_form($id);
Expand Down Expand Up @@ -456,12 +456,12 @@ public function get_submitter($id)
/**
* Standard crud_module cat getter.
*
* @param AUTO_LINK $id The entry for which the cat is sought
* @param ID_TEXT $id The entry for which the cat is sought
* @return string The cat
*/
public function get_cat($id)
{
$temp = $GLOBALS['SITE_DB']->query_select_value_if_there('news', 'news_category', array('id' => $id));
$temp = $GLOBALS['SITE_DB']->query_select_value_if_there('news', 'news_category', array('id' => intval($id)));
if (is_null($temp)) {
warn_exit(do_lang_tempcode('MISSING_RESOURCE', 'news'));
}
Expand Down
2 changes: 1 addition & 1 deletion cms/pages/modules/cms_quiz.php
Expand Up @@ -232,7 +232,7 @@ public function create_selection_list_entries()
/**
* Standard crud_module cat getter.
*
* @param AUTO_LINK $id The entry for which the cat is sought
* @param ID_TEXT $id The entry for which the cat is sought
* @return mixed The cat
*/
public function get_cat($id)
Expand Down
2 changes: 1 addition & 1 deletion cms/pages/modules_custom/cms_booking.php
Expand Up @@ -835,7 +835,7 @@ public function get_entry_rows($recache = false, $orderer = null, $where = null,
$where = array('member_id' => get_param_integer('id'));
}
if (get_option('member_booking_only') == '1') {
$_rows = $db->query_select($table . ' r ' . $join, array('DISTINCT member_id'), $where, 'ORDER BY ' . $orderer);
$_rows = $db->query_select($table . ' r ' . $join, array('DISTINCT member_id', $orderer), $where, 'ORDER BY ' . $orderer);
} else {
$_rows = $db->query_select($table . ' r ' . $join, array('id'), $where, 'ORDER BY ' . $orderer);
}
Expand Down
2 changes: 1 addition & 1 deletion sources/blocks/main_cns_involved_topics.php
Expand Up @@ -83,7 +83,7 @@ public function run($map)
$where_more .= ' AND p_cache_forum_id<>' . strval($forum2);
}
*/
$rows = $GLOBALS['FORUM_DB']->query('SELECT DISTINCT p_topic_id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts WHERE p_poster=' . strval($member_id_of) . $where_more . ' ORDER BY p_time DESC', $max, $start, false, true);
$rows = $GLOBALS['FORUM_DB']->query('SELECT DISTINCT p_topic_id,p_time FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts WHERE p_poster=' . strval($member_id_of) . $where_more . ' ORDER BY p_time DESC', $max, $start, false, true);
if (count($rows) != 0) {
if (get_bot_type() === null) {
$max_rows = $GLOBALS['FORUM_DB']->query_value_if_there('SELECT COUNT(DISTINCT p_topic_id) FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts WHERE p_poster=' . strval($member_id_of) . $where_more, false, true);
Expand Down
2 changes: 2 additions & 0 deletions sources/blocks/main_friends_list.php
Expand Up @@ -55,6 +55,8 @@ public function run($map)
{
$block_id = get_block_id($map);

require_lang('chat');

$member_id = array_key_exists('member_id', $map) ? intval($map['member_id']) : get_member();
$max = get_param_integer($block_id . '_max', array_key_exists('max', $map) ? intval($map['max']) : 12);
$start = get_param_integer($block_id . '_start', array_key_exists('start', $map) ? intval($map['start']) : 0);
Expand Down
6 changes: 6 additions & 0 deletions sources/database/oracle.php
Expand Up @@ -63,7 +63,13 @@ public function db_default_password()
*/
public function db_create_index($table_name, $index_name, $_fields, $db)
{
if (preg_match('#\(25\d\)#', $_fields) != 0) {
// We can't support this in SQL Server http://www.oratable.com/ora-01450-maximum-key-length-exceeded/.
// We assume shorter numbers than 250 are only being used on short columns anyway, which will index perfectly fine without any constraint.
return;
}
$_fields = preg_replace('#\(\d+\)#', '', $_fields);

if ($index_name[0] == '#') {
$index_name = substr($index_name, 1);
$fields = explode(',', $_fields);
Expand Down
7 changes: 7 additions & 0 deletions sources/database/postgresql.php
Expand Up @@ -62,7 +62,14 @@ public function db_create_index($table_name, $index_name, $_fields, $db)
if ($index_name[0] == '#') {
return;
}

if (preg_match('#\(25\d\)#', $_fields) != 0) {
// We can't support this in PostgreSQL
// We assume shorter numbers than 250 are only being used on short columns anyway, which will index perfectly fine without any constraint.
return;
}
$_fields = preg_replace('#\(\d+\)#', '', $_fields);

$this->db_query('CREATE INDEX index' . $index_name . '_' . strval(mt_rand(0, mt_getrandmax())) . ' ON ' . $table_name . '(' . $_fields . ')', $db);
}

Expand Down
5 changes: 5 additions & 0 deletions sources/database/sqlserver.php
Expand Up @@ -76,6 +76,11 @@ public function db_default_password()
*/
public function db_create_index($table_name, $index_name, $_fields, $db, $unique_key_field = 'id')
{
if (preg_match('#\(25\d\)#', $_fields) != 0) {
// We can't support this in SQL Server https://blogs.msdn.microsoft.com/bartd/2011/01/06/living-with-sqls-900-byte-index-key-length-limit/.
// We assume shorter numbers than 250 are only being used on short columns anyway, which will index perfectly fine without any constraint.
return;
}
$_fields = preg_replace('#\(\d+\)#', '', $_fields);

if ($index_name[0] == '#') {
Expand Down
2 changes: 1 addition & 1 deletion sources/notifications.php
Expand Up @@ -1008,7 +1008,7 @@ protected function _create_category_tree($notification_code, $id, $for_any_membe
if (!$for_any_member) {
$map['l_member_id'] = get_member();
}
$types = $db->query_select('notifications_enabled', array('DISTINCT l_code_category'), $map, 'ORDER BY id DESC', 200/*reasonable limit*/); // Already monitoring members who may not be friends
$types = $db->query_select('notifications_enabled', array('DISTINCT l_code_category', 'id'), $map, 'ORDER BY id DESC', 200/*reasonable limit*/); // Already monitoring members who may not be friends
foreach ($types as $type) {
if ($type['l_code_category'] != '') {
$page_links[] = array(
Expand Down
2 changes: 1 addition & 1 deletion sources_custom/blocks/main_google_map_users.php
Expand Up @@ -105,7 +105,7 @@ public function run($map)
}

// Data query
$query = 'SELECT m_username,mf_member_id,m_primary_group,field_' . strval($latitude_cpf_id) . ',field_' . strval($longitude_cpf_id) . ' FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_member_custom_fields f LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members m ON m.id=f.mf_member_id WHERE ' . db_string_not_equal_to('field_' . strval($longitude_cpf_id), '') . ' AND ' . db_string_not_equal_to('field_' . strval($latitude_cpf_id), '');
$query = 'SELECT m_username,mf_member_id,m_primary_group,field_' . strval($latitude_cpf_id) . ',field_' . strval($longitude_cpf_id) . ' FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_member_custom_fields f LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members m ON m.id=f.mf_member_id WHERE field_' . strval($longitude_cpf_id) . ' IS NOT NULL AND field_' . strval($latitude_cpf_id) . ' IS NOT NULL';

// Filtering
if (!array_key_exists('filter_usergroup', $map)) {
Expand Down
2 changes: 1 addition & 1 deletion sources_custom/bookings_ical.php
Expand Up @@ -183,7 +183,7 @@ function bookings_ical_script()

$id = get_param_integer('id');
$where = 'bookable_id=' . strval($id) . ' AND (b_year>' . date('Y', $time) . ' OR (b_year=' . date('Y', $time) . ' AND b_month>' . date('m', $time) . ') OR (b_year=' . date('Y', $time) . ' AND b_month=' . date('m', $time) . ' AND b_day>=' . date('d', $time) . '))';
$members_with_bookings = $GLOBALS['SITE_DB']->query('SELECT DISTINCT member_id FROM ' . get_table_prefix() . 'booking WHERE ' . $where . ' ORDER BY booked_at DESC', 10000/*reasonable limit*/);
$members_with_bookings = $GLOBALS['SITE_DB']->query('SELECT DISTINCT member_id,booked_at FROM ' . get_table_prefix() . 'booking WHERE ' . $where . ' ORDER BY booked_at DESC', 10000/*reasonable limit*/);
echo "BEGIN:VCALENDAR\n";
echo "VERSION:2.0\n";
echo "PRODID:-//ocProducts/Composr//NONSGML v1.0//EN\n";
Expand Down
3 changes: 2 additions & 1 deletion sources_custom/miniblocks/main_stars.php
Expand Up @@ -38,7 +38,8 @@
if (!is_null($username)) {
$url = $GLOBALS['FORUM_DRIVER']->member_profile_url($member_id);
$avatar_url = $GLOBALS['FORUM_DRIVER']->get_member_avatar_url($member_id);
$signature = get_translated_tempcode('gifts', $GLOBALS['FORUM_DRIVER']->get_member_row($member_id), 'm_signature', $GLOBALS['FORUM_DB']);
$just_member_row = db_map_restrict($GLOBALS['FORUM_DRIVER']->get_member_row($member_id), array('id', 'm_signature'));
$signature = get_translated_tempcode('f_members', $just_member_row, 'm_signature', $GLOBALS['FORUM_DB']);
$points = $gift['cnt'];
$rank = get_translated_text(cns_get_group_property(cns_get_member_primary_group($member_id), 'name'), $GLOBALS['FORUM_DB']);

Expand Down
4 changes: 4 additions & 0 deletions sources_custom/miniblocks/show_group_avatars.php
Expand Up @@ -72,6 +72,8 @@
}
}

echo '<div class="float_surrounder">';

$query = 'SELECT m.* FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members m WHERE ' . $where . ' ORDER BY ' . $order;
$rows = $GLOBALS['FORUM_DB']->query($query, $limit);
foreach ($rows as $row) {
Expand All @@ -94,3 +96,5 @@
</div></div>
';
}

echo '</div>';

0 comments on commit accecf5

Please sign in to comment.