Example #1
0
 function setUp()
 {
     parent::setUp();
     require_code('ecommerce');
     require_code('catalogues');
     require_code('catalogues2');
     require_code('shopping');
     require_lang('catalogues');
     require_lang('shopping');
     require_lang('ecommerce');
     if (!is_null($GLOBALS['SITE_DB']->query_value_null_ok('catalogues', 'c_name', array('c_name' => 'storetesting' . strval(get_member()))))) {
         actual_delete_catalogue('storetesting' . strval(get_member()));
     }
     $this->access_mapping = array(db_get_first_id() => 4);
     // Creating cms catalogues object
     require_code('cms/pages/modules/cms_catalogues.php');
     $this->cms_cat = new Module_cms_catalogues();
     //Creating Shopping cart object
     require_code('site/pages/modules/shopping.php');
     $this->shopping_cart = new Module_shopping();
     $username = $GLOBALS['FORUM_DRIVER']->get_username(get_member());
     $this->category_id = actual_add_catalogue('storetesting' . strval(get_member()), insert_lang(do_lang('DEFAULT_CATALOGUE_PRODUCTS_TITLE'), 2), '', 0, 1, '', 0, 1);
     $fields = array(array('ECOM_CAT_product_title', 'DESCRIPTION_TITLE', 'short_trans', 1, 1, 1, 1), array('ECOM_CAT_item_code', 'ECOM_CATD_item_code', 'random', 0, 1, 1, 1), array('ECOM_CAT_price_pre_tax', 'ECOM_CATD_price_pre_tax', 'float', 0, 1, 1, 1), array('ECOM_CAT_stock_level', 'ECOM_CATD_stock_level', 'integer', 0, 0, 1, 0), array('ECOM_CAT_stock_level_warn_at', 'ECOM_CATD_stock_level_warn_at', 'integer', 0, 0, 0, 0), array('ECOM_CAT_stock_level_maintain', 'ECOM_CATD_stock_level_maintain', 'tick', 0, 1, 0, 0), array('ECOM_CAT_tax_type', 'ECOM_CATD_tax_type', 'list', 0, 1, 0, 0, "0%|5%|17.5%", 0), array('ECOM_CAT_image', 'ECOM_CATD_image', 'picture', 0, 0, 1, 1), array('ECOM_CAT_weight', 'ECOM_CATD_weight', 'float', 0, 1, 0, 0), array('ECOM_CAT_description', 'DESCRIPTION_DESCRIPTION', 'long_trans', 0, 1, 1, 1));
     foreach ($fields as $i => $field) {
         actual_add_catalogue_field('storetesting' . strval(get_member()), lang_code_to_default_content($field[0], false, 3), lang_code_to_default_content($field[1], true, 3), $field[2] == 'tick' ? 'list' : $field[2], $i, $field[3], $field[5], $field[6], $field[2] == 'tick' ? do_lang('NO') . '|' . do_lang('YES') : (array_key_exists(7, $field) ? $field[7] : ''), $field[4], array_key_exists(5, $field) ? $field[5] : 0, array_key_exists(5, $field) ? $field[5] : 0);
     }
     $catalogue_name = 'storetesting' . strval(get_member());
     //Set Sample post values
     $fields = $GLOBALS['SITE_DB']->query_select('catalogue_fields', array('*'), array('c_name' => $catalogue_name));
     foreach ($fields as $key => $val) {
         $type = $val['cf_type'];
         $id = $val['id'];
         switch ($type) {
             case 'integer':
                 $_POST['field_' . strval($id)] = 4;
                 break;
             case 'short_trans':
                 $_POST['field_' . strval($id)] = 'Test field value';
                 break;
             case 'long_trans':
                 $_POST['field_' . strval($id)] = 'Test field value';
                 break;
             case 'float':
                 $_POST['field_' . strval($id)] = 68.34999999999999;
                 break;
             case 'list':
                 if ($val['cf_order'] = 6) {
                     //Order 6 is tax
                     $_POST['field_' . strval($id)] = 'Arizona=7.8%';
                 } elseif ($val['cf_order'] = 5) {
                     //Order 5 yes keep stock "yes/no"
                     $_POST['field_' . strval($id)] = 'yes';
                 }
                 break;
         }
     }
     $map = $this->cms_cat->get_set_field_map($catalogue_name);
     $this->product_id = actual_add_catalogue_entry($this->category_id, $validated = 0, $notes = 'test note', $allow_rating = 1, $allow_comments = 1, $allow_trackbacks = 1, $map);
 }
Example #2
0
 /**
  * Standard modular install function.
  *
  * @param  ?integer	What version we're upgrading from (NULL: new install)
  * @param  ?integer	What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
  */
 function install($upgrade_from = NULL, $upgrade_from_hack = NULL)
 {
     if (is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->create_table('classifieds_prices', array('id' => '*AUTO', 'c_catalogue_name' => 'ID_TEXT', 'c_days' => 'INTEGER', 'c_label' => 'SHORT_TRANS', 'c_price' => 'REAL'));
         $GLOBALS['SITE_DB']->create_index('classifieds_prices', 'c_catalogue_name', array('c_catalogue_name'));
         require_lang('classifieds');
         $prices = array('ONE_WEEK' => array(0.0, 7), 'ONE_MONTH' => array(5.0, 30), 'THREE_MONTHS' => array(12.0, 90), 'SIX_MONTHS' => array(20.0, 180), 'ONE_YEAR' => array(32.0, 365));
         foreach ($prices as $level => $bits) {
             list($price, $days) = $bits;
             $GLOBALS['SITE_DB']->query_insert('classifieds_prices', array('c_catalogue_name' => 'classifieds', 'c_days' => $days, 'c_label' => insert_lang(do_lang('CLASSIFIEDS_DEFAULT_PRICE_LEVEL_' . $level), 2), 'c_price' => $price));
         }
     }
 }
Example #3
0
 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  */
 function import_custom_comcode($db, $table_prefix, $old_base_dir)
 {
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'custom_bbcode');
     foreach ($rows as $row) {
         if (import_check_if_imported('custom_comcode', strval($row['bbcode_id']))) {
             continue;
         }
         global $VALID_COMCODE_TAGS;
         $test = $GLOBALS['SITE_DB']->query_value_null_ok('custom_comcode', 'tag_tag', array('tag_tag' => $row['bbcode_tag']));
         if (array_key_exists($row['bbcode_tag'], $VALID_COMCODE_TAGS) || !is_null($test)) {
             import_id_remap_put('custom_comcode', strval($row['bbcode_id']), 1);
             continue;
         }
         $GLOBALS['SITE_DB']->query_insert('custom_comcode', array('tag_tag' => $row['bbcode_tag'], 'tag_title' => insert_lang($row['bbcode_title'], 3), 'tag_description' => insert_lang($row['bbcode_desc'], 3), 'tag_replace' => $row['bbcode_replace'], 'tag_example' => $row['bbcode_example'], 'tag_parameters' => '', 'tag_enabled' => 1, 'tag_dangerous_tag' => 0, 'tag_block_tag' => 0, 'tag_textual_tag' => 1));
         import_id_remap_put('custom_comcode', strval($row['bbcode_id']), 1);
     }
 }
Example #4
0
/**
 * Make a forum.
 *
 * @param  SHORT_TEXT 	The name of the forum.
 * @param  SHORT_TEXT 	The description for the forum.
 * @param  ?AUTO_LINK	What forum category the forum will be filed with (NULL: this is the root forum).
 * @param  ?array			Permission map (NULL: do it the standard way, outside of this function). This parameter is for import/compatibility only and works upon an emulation of 'access levels' (ala ocPortal 2.5/2.6), and it is recommended to use the normal aed_module functionality for permissions setting.
 * @param  ?AUTO_LINK 	The ID of the parent forum (NULL: this is the root forum).
 * @param  integer		The position of this forum relative to other forums viewable on the same screen (if parent forum hasn't specified automatic ordering).
 * @param  BINARY			Whether post counts will be incremented if members post in the forum.
 * @param  BINARY			Whether the ordering of subforums is done automatically, alphabetically).
 * @param  LONG_TEXT		The question that is shown for newbies to the forum (blank: none).
 * @param  SHORT_TEXT	The answer to the question (blank: no specific answer.. if there's a 'question', it just requires a click-through).
 * @param  SHORT_TEXT	Either blank for no redirection, the ID of another forum we are mirroring, or a URL to redirect to.
 * @param  ID_TEXT		The order the topics are shown in, by default.
 * @param  BINARY			Whether the forum is threaded.
 * @return AUTO_LINK		The ID of the newly created forum.
 */
function ocf_make_forum($name, $description, $category_id, $access_mapping, $parent_forum, $position = 1, $post_count_increment = 1, $order_sub_alpha = 0, $intro_question = '', $intro_answer = '', $redirection = '', $order = 'last_post', $is_threaded = 0)
{
    if ($category_id == -1) {
        $category_id = NULL;
    }
    if ($parent_forum == -1) {
        $parent_forum = NULL;
    }
    if (get_page_name() != 'admin_import') {
        if (!is_null($category_id) && function_exists('ocf_ensure_category_exists')) {
            ocf_ensure_category_exists($category_id);
        }
        if (!is_null($parent_forum) && function_exists('ocf_ensure_forum_exists')) {
            ocf_ensure_forum_exists($parent_forum);
        }
    }
    $forum_id = $GLOBALS['FORUM_DB']->query_insert('f_forums', array('f_name' => $name, 'f_description' => insert_lang($description, 2, $GLOBALS['FORUM_DB']), 'f_category_id' => $category_id, 'f_parent_forum' => $parent_forum, 'f_position' => $position, 'f_order_sub_alpha' => $order_sub_alpha, 'f_post_count_increment' => $post_count_increment, 'f_intro_question' => insert_lang($intro_question, 3, $GLOBALS['FORUM_DB']), 'f_intro_answer' => $intro_answer, 'f_cache_num_topics' => 0, 'f_cache_num_posts' => 0, 'f_cache_last_topic_id' => NULL, 'f_cache_last_forum_id' => NULL, 'f_cache_last_title' => '', 'f_cache_last_time' => NULL, 'f_cache_last_username' => '', 'f_cache_last_member_id' => NULL, 'f_redirection' => $redirection, 'f_order' => $order, 'f_is_threaded' => $is_threaded), true);
    // Set permissions
    if (!is_null($access_mapping)) {
        $groups = $GLOBALS['OCF_DRIVER']->get_usergroup_list(false, true);
        foreach (array_keys($groups) as $group_id) {
            $level = 0;
            // No-access
            if (array_key_exists($group_id, $access_mapping)) {
                $level = $access_mapping[$group_id];
            }
            if ($level >= 1) {
                $GLOBALS['FORUM_DB']->query_insert('group_category_access', array('module_the_name' => 'forums', 'category_name' => strval($forum_id), 'group_id' => $group_id));
                if ($level == 1) {
                    $GLOBALS['FORUM_DB']->query_insert('gsp', array('specific_permission' => 'submit_lowrange_content', 'group_id' => $group_id, 'the_page' => '', 'module_the_name' => 'forums', 'category_name' => strval($forum_id), 'the_value' => 0));
                    $GLOBALS['FORUM_DB']->query_insert('gsp', array('specific_permission' => 'submit_midrange_content', 'group_id' => $group_id, 'the_page' => '', 'module_the_name' => 'forums', 'category_name' => strval($forum_id), 'the_value' => 0));
                }
                if ($level >= 3) {
                    $GLOBALS['FORUM_DB']->query_insert('gsp', array('specific_permission' => 'bypass_validation_lowrange_content', 'group_id' => $group_id, 'the_page' => '', 'module_the_name' => 'forums', 'category_name' => strval($forum_id), 'the_value' => 1));
                }
                if ($level >= 4) {
                    $GLOBALS['FORUM_DB']->query_insert('gsp', array('specific_permission' => 'bypass_validation_midrange_content', 'group_id' => $group_id, 'the_page' => '', 'module_the_name' => 'forums', 'category_name' => strval($forum_id), 'the_value' => 1));
                }
                // 2=May post, [3=May post instantly , 4=May start topics instantly , 5=Moderator  --  these ones will not be treated specially, so as to avoid overriding permissions unnecessary - let the admins configure it optimally manually]
            }
        }
    }
    log_it('ADD_FORUM', strval($forum_id), $name);
    return $forum_id;
}
/**
 * Add a multi moderation to the system.
 *
 * @param  SHORT_TEXT	The name of the multi moderation.
 * @param  LONG_TEXT		The post text to add when applying (blank: don't add a post).
 * @param  ?AUTO_LINK	The forum to move the topic when applying (NULL: do not move).
 * @param  ?BINARY		The pin state after applying (NULL: unchanged).
 * @param  ?BINARY		The sink state after applying (NULL: unchanged).
 * @param  ?BINARY		The open state after applying (NULL: unchanged).
 * @param  SHORT_TEXT	The forum multi code for where this multi moderation may be applied.
 * @param  SHORT_TEXT	The title suffix.
 * @return AUTO_LINK		The ID of the multi moderation just added.
 */
function ocf_make_multi_moderation($name, $post_text, $move_to, $pin_state, $sink_state, $open_state, $forum_multi_code = '*', $title_suffix = '')
{
    if ($move_to == -1) {
        $move_to = NULL;
    }
    if ($pin_state == -1) {
        $pin_state = NULL;
    }
    if ($open_state == -1) {
        $open_state = NULL;
    }
    if ($sink_state == -1) {
        $sink_state = NULL;
    }
    $id = $GLOBALS['FORUM_DB']->query_insert('f_multi_moderations', array('mm_name' => insert_lang($name, 3, $GLOBALS['FORUM_DB']), 'mm_post_text' => $post_text, 'mm_move_to' => $move_to, 'mm_pin_state' => $pin_state, 'mm_sink_state' => $sink_state, 'mm_open_state' => $open_state, 'mm_forum_multi_code' => $forum_multi_code, 'mm_title_suffix' => $title_suffix), true);
    log_it('ADD_MULTI_MODERATION', strval($id), $name);
    return $id;
}
Example #6
0
/**
 * Explictly sets the meta information for the specified resource.
 *
 * @param  ID_TEXT		The type of resource (e.g. download)
 * @param  ID_TEXT		The ID of the resource
 * @param  SHORT_TEXT	The keywords to use
 * @param  SHORT_TEXT	The description to use
 */
function seo_meta_set_for_explicit($type, $id, $keywords, $description)
{
    if ($description == STRING_MAGIC_NULL) {
        return;
    }
    if ($keywords == STRING_MAGIC_NULL) {
        return;
    }
    $description = str_replace(chr(10), ' ', $description);
    $rows = $GLOBALS['SITE_DB']->query_select('seo_meta', array('meta_keywords', 'meta_description'), array('meta_for_type' => $type, 'meta_for_id' => $id), '', 1);
    if (array_key_exists(0, $rows)) {
        lang_remap($rows[0]['meta_keywords'], $keywords);
        lang_remap($rows[0]['meta_description'], $description);
    } else {
        $GLOBALS['SITE_DB']->query_insert('seo_meta', array('meta_for_type' => $type, 'meta_for_id' => $id, 'meta_keywords' => insert_lang($keywords, 2), 'meta_description' => insert_lang($description, 2)));
    }
    if (function_exists('decache')) {
        decache('side_tag_cloud');
    }
    if (function_exists('persistant_cache_delete')) {
        persistant_cache_delete(array('seo', $type, $id));
    }
}
Example #7
0
 /**
  * Standard modular install function.
  *
  * @param  ?integer	What version we're upgrading from (NULL: new install)
  * @param  ?integer	What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
  */
 function install($upgrade_from = NULL, $upgrade_from_hack = NULL)
 {
     if (!is_null($upgrade_from) && $upgrade_from < 5) {
         $GLOBALS['SITE_DB']->delete_table_field('ticket_types', 'send_sms_to');
     }
     if (!is_null($upgrade_from) && $upgrade_from < 4) {
         $GLOBALS['SITE_DB']->add_table_field('ticket_types', 'guest_emails_mandatory', 'BINARY', 0);
         $GLOBALS['SITE_DB']->add_table_field('ticket_types', 'search_faq', 'BINARY', 0);
         $GLOBALS['SITE_DB']->add_table_field('ticket_types', 'cache_lead_time', '?TIME');
     }
     if ($upgrade_from < 3 || is_null($upgrade_from)) {
         add_specific_permission('SUPPORT_TICKETS', 'support_operator', false);
     }
     if (is_null($upgrade_from) || $upgrade_from < 4) {
         add_config_option('TICKET_MEMBER_FORUMS', 'ticket_member_forums', 'tick', 'return \'0\';', 'FEATURE', 'SUPPORT_TICKETS');
         add_config_option('TICKET_TYPE_FORUMS', 'ticket_type_forums', 'tick', 'return \'0\';', 'FEATURE', 'SUPPORT_TICKETS');
         $GLOBALS['SITE_DB']->create_table('tickets', array('ticket_id' => '*SHORT_TEXT', 'topic_id' => 'AUTO_LINK', 'forum_id' => 'AUTO_LINK', 'ticket_type' => 'SHORT_TRANS'));
     }
     if (!is_null($upgrade_from) && $upgrade_from < 2) {
         $GLOBALS['SITE_DB']->query_update('config', array('eval' => 'return do_lang(\'NEW_TICKET_WELCOME\');'), array('the_name' => 'ticket_text'), '', 1);
         if ($GLOBALS['OPTIONS']['ticket_text']['c_set'] == 1) {
             set_option('ticket_text', '[html]' . get_option('ticket_text') . '[/html]');
         } else {
             set_option('ticket_text', do_lang('NEW_TICKET_WELCOME'));
         }
         return;
     }
     require_lang('tickets');
     if (is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->create_table('ticket_types', array('ticket_type' => '*SHORT_TRANS', 'guest_emails_mandatory' => 'BINARY', 'search_faq' => 'BINARY', 'cache_lead_time' => '?TIME'));
         $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true);
         $default_types = array('TT_OTHER', 'TT_COMPLAINT');
         foreach ($default_types as $type) {
             $GLOBALS['SITE_DB']->query_insert('ticket_types', array('ticket_type' => insert_lang(do_lang($type), 1), 'guest_emails_mandatory' => 0, 'search_faq' => 0, 'cache_lead_time' => NULL));
             foreach (array_keys($groups) as $id) {
                 $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'tickets', 'category_name' => do_lang($type), 'group_id' => $id));
             }
         }
         add_config_option('PAGE_TEXT', 'ticket_text', 'transtext', 'return do_lang(\'NEW_TICKET_WELCOME\');', 'FEATURE', 'SUPPORT_TICKETS');
         add_config_option('TICKET_FORUM_NAME', 'ticket_forum_name', 'forum', 'require_lang(\'tickets\'); return do_lang(\'TICKET_FORUM_NAME\',\'\',\'\',\'\',get_site_default_lang());', 'FEATURE', 'SUPPORT_TICKETS');
         add_specific_permission('SUPPORT_TICKETS', 'view_others_tickets', false);
         add_menu_item_simple('main_website', NULL, 'SUPPORT_TICKETS', '_SEARCH:tickets:type=misc');
     }
 }
Example #8
0
 /**
  * Special import-esque function to aid switching to OCF after importing forum previously served by a forum driver.
  *
  * @return tempcode	Information about progress
  */
 function ocf_switch()
 {
     $out = new ocp_tempcode();
     $todos = array('USER' => array('member', db_get_first_id(), NULL), 'GROUP' => array('group', NULL, 'group_id'));
     foreach ($todos as $db_abstraction => $definition) {
         list($import_code, $default_id, $field_name_also) = $definition;
         $count = 0;
         $extra = is_null($field_name_also) ? '' : ' OR ' . db_string_equal_to('m_name', $field_name_also);
         $fields = $GLOBALS['SITE_DB']->query('SELECT m_table,m_name FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'db_meta WHERE (NOT (m_table LIKE \'' . db_encode_like('f_%') . '\')) AND (' . db_string_equal_to('m_type', $db_abstraction) . ' OR ' . db_string_equal_to('m_type', '*' . $db_abstraction) . ' OR ' . db_string_equal_to('m_type', '?' . $db_abstraction) . $extra . ')');
         foreach ($fields as $field) {
             if ($field['m_table'] == 'stats') {
                 continue;
             }
             // Lots of data and it's not important
             //echo '(working) '.$field['m_table'].'/'.$field['m_name'].'<br />';
             $values = $GLOBALS['SITE_DB']->query_select($field['m_table'], array('*'));
             foreach ($values as $value) {
                 $current = $value[$field['m_name']];
                 $remapped = import_id_remap_get($import_code, $current, true);
                 if (is_null($remapped)) {
                     $remapped = $default_id;
                 }
                 if (!is_null($remapped)) {
                     $value2 = $value;
                     $value2[$field['m_name']] = -$remapped;
                     $c = $GLOBALS['SITE_DB']->query_update($field['m_table'], $value2, $value, '', NULL, NULL, true, true);
                     if (is_null($c)) {
                         $GLOBALS['SITE_DB']->query_delete($field['m_table'], $value);
                     } else {
                         $count += $c;
                     }
                 } else {
                     $GLOBALS['SITE_DB']->query_delete($field['m_table'], $value);
                 }
             }
             $GLOBALS['SITE_DB']->query('UPDATE ' . $GLOBALS['SITE_DB']->get_table_prefix() . $field['m_table'] . ' SET ' . $field['m_name'] . '=-' . $field['m_name'] . ' WHERE ' . $field['m_name'] . '<0');
         }
         $out->attach(paragraph(do_lang_tempcode('OCF_CONVERTED_' . $db_abstraction, $count == 0 ? '?' : strval($count))));
     }
     // info.php
     global $FILE_BASE;
     $info_file = (file_exists('use_comp_name') ? array_key_exists('COMPUTERNAME', $_ENV) ? $_ENV['COMPUTERNAME'] : $_SERVER['SERVER_NAME'] : 'info') . '.php';
     $info = @fopen($FILE_BASE . '/' . $info_file, 'wt') or intelligent_write_error($FILE_BASE . '/' . $info_file);
     fwrite($info, "<" . "?php\n");
     global $SITE_INFO;
     $SITE_INFO['forum_type'] = 'ocf';
     $SITE_INFO['ocf_table_prefix'] = $SITE_INFO['table_prefix'];
     $SITE_INFO['db_forums'] = $SITE_INFO['db_site'];
     $SITE_INFO['db_forums_host'] = array_key_exists('db_site_host', $SITE_INFO) ? $SITE_INFO['db_site_host'] : 'localhost';
     $SITE_INFO['db_forums_user'] = $SITE_INFO['db_site_user'];
     $SITE_INFO['db_forums_password'] = $SITE_INFO['db_site_password'];
     $SITE_INFO['board_prefix'] = get_base_url();
     foreach ($SITE_INFO as $key => $val) {
         $_val = str_replace('\\', '\\\\', $val);
         fwrite($info, '$SITE_INFO[\'' . $key . '\']=\'' . $_val . "';\n");
     }
     fwrite($info, "?" . ">\n");
     fclose($info);
     fix_permissions($FILE_BASE . '/' . $info_file);
     sync_file($FILE_BASE . '/' . $info_file);
     $out->attach(paragraph(do_lang_tempcode('OCF_CONVERTED_INFO')));
     $LANG = get_site_default_lang();
     $trans5 = insert_lang(do_lang('FORUM'), 1, NULL, false, NULL, $LANG);
     $GLOBALS['SITE_DB']->query_insert('zones', array('zone_name' => 'forum', 'zone_title' => insert_lang(do_lang('SECTION_FORUMS'), 1), 'zone_default_page' => 'forumview', 'zone_header_text' => $trans5, 'zone_theme' => '-1', 'zone_wide' => NULL, 'zone_require_session' => 0, 'zone_displayed_in_menu' => 1));
     require_code('menus2');
     add_menu_item_simple('zone_menu', NULL, 'SECTION_FORUMS', 'forum' . ':forumview', 0, 1);
     return $out;
 }
Example #9
0
 /**
  * The actualiser to set match-key access.
  *
  * @return tempcode		The UI
  */
 function set_keys_access()
 {
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/matchkeysecurity';
     $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_permissions';
     $title = get_page_title('PAGE_MATCH_KEY_ACCESS');
     // Delete to cleanup
     $GLOBALS['SITE_DB']->query('DELETE FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'group_page_access WHERE page_name LIKE \'' . db_encode_like('%:%') . '\'');
     $mkeylang = collapse_2d_complexity('id', 'k_message', $GLOBALS['SITE_DB']->query_select('match_key_messages', array('id', 'k_message')));
     $GLOBALS['SITE_DB']->query_delete('match_key_messages');
     $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true);
     foreach ($_POST as $key => $val) {
         if (get_magic_quotes_gpc()) {
             $val = stripslashes($val);
         }
         // See if we can tidy it back to a page-link (assuming it's not one already)
         $page_link = url_to_pagelink($val, true);
         if ($page_link != '') {
             $val = $page_link;
         }
         if (substr($key, 0, 4) == 'key_' && $val != '') {
             foreach (array_keys($groups) as $gid) {
                 if (post_param_integer('p_' . substr($key, 4) . '__' . strval($gid), 0) == 1) {
                     $GLOBALS['SITE_DB']->query_insert('group_page_access', array('zone_name' => '/', 'page_name' => $val, 'group_id' => $gid));
                 }
             }
         }
         if (substr($key, 0, 5) == 'mkey_' && $val != '') {
             $id = substr($key, 5);
             if (substr($id, 0, 4) == 'new_' || !array_key_exists(intval($id), $mkeylang)) {
                 $GLOBALS['SITE_DB']->query_insert('match_key_messages', array('k_message' => insert_lang(post_param('msg_' . $id), 2), 'k_match_key' => $val));
             } else {
                 $GLOBALS['SITE_DB']->query_insert('match_key_messages', array('k_message' => lang_remap($mkeylang[intval($id)], post_param('msg_' . $id)), 'k_match_key' => $val));
                 unset($mkeylang[intval($id)]);
             }
         }
     }
     foreach ($mkeylang as $lid) {
         delete_lang($lid);
     }
     decache('main_sitemap');
     breadcrumb_set_parents(array(array('_SELF:_SELF:keys', do_lang_tempcode('PAGE_MATCH_KEY_ACCESS'))));
     breadcrumb_set_self(do_lang_tempcode('DONE'));
     // Show it worked / Refresh
     $url = build_url(array('page' => '_SELF', 'type' => 'keys'), '_SELF');
     return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
 }
Example #10
0
 /**
  * Read in data posted by an add/edit form
  *
  * @param  boolean	Whether to insert unknown workflows into the database. For adding this should be true, otherwise false (the default)
  * @return array		(workflow_id, workflow_name, array(approval point IDs=>names), default)
  */
 function read_in_data($insert_if_needed = false)
 {
     require_lang('workflows');
     // Grab the given name. We allow spaces, letters and numbers.
     $name = implode(' ', array_map('strip_tags', explode(' ', trim(post_param('name')))));
     // Look for an existing workflow with this name
     $workflows = get_all_workflows();
     if (in_array($name, $workflows)) {
         // Found one, use it
         $workflow_id = current(array_keys($workflows, $name));
     } elseif ($insert_if_needed) {
         // Couldn't find any. Let's make one, with a dummy approval point.
         // HACKHACK We should use a normalised table with an ID column
         $workflow_id = insert_lang($name, 3);
         $GLOBALS['SITE_DB']->query_insert('workflow_requirements', array('workflow_name' => $workflow_id, 'is_default' => 0, 'the_position' => 0, 'workflow_approval_name' => 0));
     } else {
         warn_exit(do_lang('_MISSING_RESOURCE', $name));
     }
     // Grab all of the requested points
     $points = array_map('trim', explode("\n", trim(post_param('points'))));
     // Discard whitespace
     $temp_points = array();
     foreach ($points as $p) {
         if (strlen(trim($p)) > 0) {
             $temp_points[] = trim($p);
         }
     }
     $points = $temp_points;
     unset($temp_points);
     // Clean them up a bit. We'll allow spaces, but no other punctuation.
     $clean_points = array();
     foreach ($points as $p) {
         $clean_points[] = implode(' ', array_map('strip_tags', explode(' ', $p)));
     }
     $points = $clean_points;
     unset($clean_points);
     // Find any points which are already defined
     $all_points = get_all_approval_points();
     $point_ids = array();
     foreach ($points as $p) {
         if (in_array($p, array_values($all_points))) {
             // This already exists. Use the existing version.
             $point_id = current(array_keys($all_points, $p));
             $point_ids[$point_id] = $p;
         } else {
             // This doesn't exist yet. Define it now.
             // HACKHACK We should use a normalised table with an ID field
             $point_id = insert_lang($p, 3);
             $point_ids[$point_id] = $p;
         }
         // Make sure that there are groups allowed to approve this point
         $this_key = NULL;
         foreach (array_keys($_POST) as $post_key) {
             if (strpos($post_key, 'code_') === 0) {
                 $this_key = intval(str_replace('code_', '', $post_key));
             } elseif (strpos($post_key, 'redef_') === 0) {
                 $this_key = intval(str_replace('redef_', '', $post_key));
             }
         }
         if (is_null($this_key)) {
             // If we can't find any then it may be that the browser didn't send
             // us the ticks, since the user didn't change them (notably Chrome
             // does this).
             // If this is the case then we leave existing points alone...
             $has_defaults = $GLOBALS['SITE_DB']->query_select('workflow_requirements', array('*'), array('workflow_approval_name' => $point_id));
             if (count($has_defaults) > 0) {
                 continue;
             } else {
                 // ... but this is an error is there are no existing permissions
                 // Clean up any dummies we made
                 $GLOBALS['SITE_DB']->query_delete('workflow_requirements', array('workflow_approval_name' => 0));
                 warn_exit(do_lang('WORKFLOW_POINT_MUST_HAVE_GROUP', $p));
             }
         }
         // Clear previous permissions for this approval point
         $GLOBALS['SITE_DB']->query_delete('workflow_permissions', array('workflow_approval_name' => $point_id));
         // Insert the new permissions for this approval point
         if (array_key_exists('groups_' . strval($this_key), $_POST)) {
             foreach ($_POST['groups_' . strval($this_key)] as $k => $v) {
                 $GLOBALS['SITE_DB']->query_insert('workflow_permissions', array('usergroup' => intval($k), 'workflow_approval_name' => $point_id, 'validated' => 1));
             }
         }
         if (array_key_exists('redef_groups_' . strval($this_key), $_POST)) {
             foreach ($_POST['redef_groups_' . strval($this_key)] as $k => $v) {
                 $GLOBALS['SITE_DB']->query_insert('workflow_permissions', array('usergroup' => intval($k), 'workflow_approval_name' => $point_id, 'validated' => 1));
             }
         }
     }
     // Now replace the workflow requirements. Add the new points (existing
     // instances will be replaced, so we don't need to worry about duplicates)
     $point_names = array_flip($point_ids);
     $points_we_want = array();
     foreach ($points as $p) {
         add_requirement_to_workflow($point_names[$p], $workflow_id);
         $points_we_want[] = $point_names[$p];
     }
     // Now we remove those points which are not wanted. We have to do this
     // after the insertions, since we need to keep at least one approval point
     // for the workflow in order for it to exist.
     $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'workflow_requirements WHERE workflow_name=' . strval($workflow_id) . ' AND workflow_approval_name NOT IN (' . implode(',', $points_we_want) . ')');
     return array($workflow_id, $name, $point_ids, post_param_integer('is_default', 0) == 1);
 }
Example #11
0
/**
 * Add a menu item.
 *
 * @param  SHORT_TEXT	The name of the menu to add the item to.
 * @param  integer		The relative order of this item on the menu.
 * @param  ?AUTO_LINK	The menu item ID of the parent branch of the menu item (NULL: is on root).
 * @param  SHORT_TEXT	The caption.
 * @param  SHORT_TEXT	The URL (in entry point form).
 * @param  BINARY			Whether people who may not view the entry point do not see the link.
 * @param  SHORT_TEXT	Match-keys to identify what pages the item is shown on.
 * @param  BINARY			Whether it is an expanded branch.
 * @param  BINARY			Whether the link will open in a new window.
 * @param  SHORT_TEXT	The tooltip (blank: none).
 * @return AUTO_LINK		The ID of the newly added menu item.
 */
function add_menu_item($menu, $order, $parent, $caption, $url, $check_permissions, $page_only, $expanded, $new_window, $caption_long)
{
    $id = $GLOBALS['SITE_DB']->query_insert('menu_items', array('i_menu' => $menu, 'i_order' => $order, 'i_parent' => $parent, 'i_caption' => insert_lang($caption, 1), 'i_caption_long' => insert_lang($caption_long, 1), 'i_url' => $url, 'i_check_permissions' => $check_permissions, 'i_page_only' => $page_only, 'i_expanded' => $expanded, 'i_new_window' => $new_window, 'i_theme_img_code' => ''), true);
    log_it('ADD_MENU_ITEM', strval($id), $caption);
    return $id;
}
Example #12
0
            $label = post_param('label_' . $matches[1] . '_' . $matches[2], '');
            $price = post_param('price_' . $matches[1] . '_' . $matches[2], '');
            if ($catalogue != '' && $days != '' && $label != '' && $price != '') {
                if ($matches[1] == 'existing') {
                    $_label = $GLOBALS['SITE_DB']->query_value_null_ok('classifieds_prices', 'c_label', array('id' => intval($matches[2])));
                    if (is_null($_label)) {
                        $matches[1] = 'new';
                    }
                    // Was lost, so add as new
                }
                if ($matches[1] == 'existing') {
                    // Edit
                    $GLOBALS['SITE_DB']->query_update('classifieds_prices', array('c_catalogue_name' => $catalogue, 'c_days' => intval($days), 'c_label' => lang_remap($_label, $label), 'c_price' => floatval($price)), array('id' => intval($matches[2])), '', 1);
                } else {
                    // Add
                    $GLOBALS['SITE_DB']->query_insert('classifieds_prices', array('c_catalogue_name' => $catalogue, 'c_days' => intval($days), 'c_label' => insert_lang($label, 2), 'c_price' => floatval($price)));
                }
            } else {
                if ($matches[1] == 'existing') {
                    // Delete
                    $GLOBALS['SITE_DB']->query_delete('classifieds_prices', array('id' => intval($matches[2])), '', 1);
                }
            }
        }
    }
    attach_message(do_lang_tempcode('SUCCESS', 'inform'));
}
$title = get_page_title('CLASSIFIEDS');
$_prices = $GLOBALS['SITE_DB']->query_select('classifieds_prices', array('*'), NULL, 'ORDER BY c_catalogue_name,c_days,c_price');
$prices = array();
foreach ($_prices as $_price) {
 /**
  * Standard aed_module add actualiser.
  *
  * @return ID_TEXT		The entry added
  */
 function add_actualisation()
 {
     $tag = post_param('tag');
     require_code('type_validation');
     if (!is_alphanumeric($tag, true)) {
         warn_exit(do_lang_tempcode('BAD_CODENAME'));
     }
     global $VALID_COMCODE_TAGS;
     $test = $GLOBALS['SITE_DB']->query_value_null_ok('custom_comcode', 'tag_tag', array('tag_tag' => $tag));
     if (array_key_exists($tag, $VALID_COMCODE_TAGS) || !is_null($test)) {
         warn_exit(do_lang_tempcode('ALREADY_EXISTS', escape_html($tag)));
     }
     $GLOBALS['SITE_DB']->query_insert('custom_comcode', array('tag_tag' => $tag, 'tag_title' => insert_lang(post_param('title'), 3), 'tag_description' => insert_lang(post_param('description'), 3), 'tag_replace' => post_param('replace'), 'tag_example' => post_param('example'), 'tag_parameters' => post_param('parameters'), 'tag_enabled' => post_param_integer('enabled', 0), 'tag_dangerous_tag' => post_param_integer('dangerous_tag', 0), 'tag_block_tag' => post_param_integer('block_tag', 0), 'tag_textual_tag' => post_param_integer('textual_tag', 0)));
     log_it('ADD_' . $this->lang_type, $tag);
     return $tag;
 }
Example #14
0
 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  */
 function import_news_and_categories($db, $table_prefix, $old_base_dir)
 {
     require_code('news');
     require_code('galleries2');
     //check is the comment forum configured in ocPortal
     $this->test_for_comments_forum();
     // Can we comment the news?
     $com = 1;
     $forum_name = get_option('comments_forum_name');
     ocf_over_msn();
     //used to fixed the correct forum prefix
     $forum_id = $GLOBALS['FORUM_DRIVER']->forum_id_from_name($forum_name);
     ocf_over_local();
     //used to fixed the correct forum prefix
     /* old import reviews code, as part of the news. NOTE: now they are imported as catalogues entries
     		// Reviews (imports into 'community')
     		$rows=$db->query('SELECT r.id AS review_id, r.title AS review_title, r.description AS review_description, r.field1 AS rf1, r.field2 AS rf2, r.field3 AS rf3, r.field4 AS rf4, r.field5 AS rf5, r.field6 AS rf6, r.field7 AS rf7, r.*, rc.title AS rc_title, rc.description AS rc_description, rc.field1 AS rcf1, rc.field2 AS rcf2, rc.field3 AS rcf3, rc.field4 AS rcf4, rc.field5 AS rcf5, rc.field6 AS rcf6, rc.field7 AS rcf7, rc.* FROM '.$table_prefix.'reviews r LEFT JOIN '.$table_prefix.'reviews_sections rc ON r.id_cat=rc.id');
     
     		foreach ($rows as $row)
     		{
     			$cat_id=$this->get_news_category_id($row['review_title'],'community');
     			$review_description=$row['review_description'];
     			for ($i=1;$i<=7;$i++)
     			{
     				if (strlen($row[strval('rcf'.$i)])>0)
     				{
     					$review_description.=chr(10).$row[strval('rcf'.$i)].': '.$row[strval('rf'.$i)];
     				}
     			}
     			$review_description.=chr(10).'Views: '.strval(intval($row['click']));
     
     			ocf_over_msn(); //used to fixed the correct forum prefix
     			$new_id=add_news($row['review_title'],html_to_comcode($review_description),$row['idauth'],$row['validate'],$com,1,1,'',html_to_comcode($row['review']),$cat_id,array(),$row['date'],get_member(),$row['click']);
     			ocf_over_local(); //used to fixed the correct forum prefix
     
     
     			// Comments
     			$comments=$db->query('SELECT * FROM '.$table_prefix.'reviews_comments WHERE id='.strval($row['review_id']).' ORDER BY data');
     			if (!is_null($forum_id))
     			{
     				foreach ($comments as $comment)
     				{
     					$member=$comment['id_autore']; //$GLOBALS['FORUM_DRIVER']->get_member_from_username($comment['userid']);
     
     					ocf_over_msn(); //used to fixed the correct forum prefix
     					if (is_null($member)) $member=$GLOBALS['FORUM_DRIVER']->get_guest_id();
     					ocf_over_local(); //used to fixed the correct forum prefix
     
     					$title='';
     					$post=$comment['testo'];
     					$content_url=build_url(array('page'=>'news','id'=>$new_id,'type'=>'view'),get_module_zone('news'));
     
     					ocf_over_msn(); //used to fixed the correct forum prefix
     					$GLOBALS['FORUM_DRIVER']->make_post_forum_topic(
     						$forum_name,
     						'news_'.strval($new_id),
     						$member,
     						$title,
     						html_to_comcode($post),
     						$row['title'],
     						do_lang('COMMENT'),
     						$content_url->evaluate()
     					);
     					ocf_over_local(); //used to fixed the correct forum prefix
     				}
     			}
     		} end of old import reviews code */
     // Blogs (imports into community for author)
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'blog');
     foreach ($rows as $row) {
         $blog_cat_id = $GLOBALS['SITE_DB']->query_value_null_ok('news_categories', 'id', array('nc_owner' => $row['creato']));
         $row['titolo'] = @html_entity_decode($row['titolo'], ENT_QUOTES, get_charset());
         ocf_over_msn();
         //used to fixed the correct forum prefix
         $submitting_member_id = $GLOBALS['FORUM_DRIVER']->get_member_from_username($row['autore']);
         if (is_null($submitting_member_id)) {
             $submitting_member_id = $GLOBALS['FORUM_DRIVER']->get_guest_id();
         }
         ocf_over_local();
         //used to fixed the correct forum prefix
         if (is_null($blog_cat_id)) {
             ocf_over_msn();
             //used to fixed the correct forum prefix
             $p_nc_title = insert_lang($row['titolo'], 2);
             ocf_over_local();
             //used to fixed the correct forum prefix
             $blog_cat_id = $GLOBALS['SITE_DB']->query_insert('news_categories', array('nc_title' => $p_nc_title, 'nc_img' => 'newscats/community', 'notes' => '', 'nc_owner' => $submitting_member_id), true);
             ocf_over_msn();
             //used to fixed the correct forum prefix
             $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true);
             ocf_over_local();
             //used to fixed the correct forum prefix
             foreach (array_keys($groups) as $group_id) {
                 $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'news', 'category_name' => strval($blog_cat_id), 'group_id' => $group_id));
             }
         }
         // Blog description goes to first post in blog
         ocf_over_msn();
         //used to fixed the correct forum prefix
         $new_id = add_news($row['titolo'], '', $row['autore'], $row['validate'], 1, $com, 1, '', html_to_comcode($row['descrizione']), $blog_cat_id, array(), $row['creato'], $submitting_member_id);
         ocf_over_local();
         //used to fixed the correct forum prefix
         $blog_posts = $db->query('SELECT * FROM ' . $table_prefix . 'blog_post WHERE id_blog=' . strval($row['id']));
         foreach ($blog_posts as $blog_post) {
             if (import_check_if_imported('blog_post', strval($blog_post['id']))) {
                 continue;
             }
             ocf_over_msn();
             //used to fixed the correct forum prefix
             $new_id = add_news($row['titolo'], '', $row['autore'], $row['validate'], 1, $com, 1, '', html_to_comcode($blog_post['post']), $blog_cat_id, array(), $blog_post['data'], $submitting_member_id);
             ocf_over_local();
             //used to fixed the correct forum prefix
             import_id_remap_put('blog_post', strval($blog_post['id']), $new_id);
             //import blog rating too
             $this->_import_ratings($db, 'news', $row['id'], $new_id, $row['rate'], $table_prefix);
             // Comments
             $comments = $db->query('SELECT * FROM ' . $table_prefix . 'blog_commenti WHERE id_blog=' . strval($blog_post['id']) . ' ORDER BY data');
             if (!is_null($forum_id)) {
                 foreach ($comments as $comment) {
                     ocf_over_msn();
                     //used to fixed the correct forum prefix
                     $member = $GLOBALS['FORUM_DRIVER']->get_member_from_username($comment['autore']);
                     if (is_null($member)) {
                         $member = $GLOBALS['FORUM_DRIVER']->get_guest_id();
                     }
                     ocf_over_local();
                     //used to fixed the correct forum prefix
                     $title = '';
                     $post = $comment['commento'];
                     $content_url = build_url(array('page' => 'news', 'id' => $new_id, 'type' => 'view'), get_module_zone('news'));
                     ocf_over_msn();
                     //used to fixed the correct forum prefix
                     $GLOBALS['FORUM_DRIVER']->make_post_forum_topic($forum_name, 'news_' . strval($new_id), $member, $title, html_to_comcode($post), $row['titolo'], do_lang('COMMENT'), $content_url->evaluate());
                     ocf_over_local();
                     //used to fixed the correct forum prefix
                 }
             }
         }
         //import blog images in personal galleries or in synch onces
         if (addon_installed('galleries')) {
             $blog_pimages = $db->query('SELECT * FROM ' . $table_prefix . 'blog_pimages WHERE iduser='******'SITE_DB']->query_value_null_ok('galleries', 'name', array('is_member_synched' => 1));
                 $root_gallery = is_null($pcc_gallery) ? 'root' : $pcc_gallery;
                 $ocp_path = get_custom_file_base();
                 //copy watermark image, to insure it is copied
                 $save_filename = $old_base_dir . 'mkportal/modules/gallery/wt.png';
                 //NOTE: this is the default watermark image in MKPortal, if customer needs to use another image, he/she needs to overwite it
                 $watermark_image = '';
                 if (file_exists($save_filename)) {
                     $copy_destination = $ocp_path . '/uploads/watermarks/wt.png';
                     @copy($save_filename, $copy_destination);
                     fix_permissions($copy_destination);
                     sync_file($copy_destination);
                     $watermark_image = get_custom_base_url() . '/uploads/watermarks/wt.png';
                 }
                 //now we need to get MKPortal settings for the watermark images
                 $conf_rows = $db->query('SELECT * FROM ' . $table_prefix . 'config WHERE ' . db_string_equal_to('chiave', 'watermark_pos') . ' OR ' . db_string_equal_to('chiave', 'watermark_enable'));
                 $watermark_pos = 2;
                 //Possible values: 0 - Top-right; 1 - Center; 2 - Bottom-right (default for MKPortal)
                 $watermark_enable = 0;
                 //by default it is disabled
                 foreach ($conf_rows as $conf_row) {
                     if (isset($conf_row['chiave']) && $conf_row['chiave'] == 'watermark_pos') {
                         $watermark_pos = $conf_row['valore'];
                         if ($watermark_pos == 1) {
                             $watermark_pos = 2;
                             //ocPortal doesn't have watermark center position, so we will use the mkPortal default position: Bottom-right
                         }
                         continue;
                     }
                     if (isset($conf_row['chiave']) && $conf_row['chiave'] == 'watermark_enable') {
                         $watermark_enable = $conf_row['valore'];
                         continue;
                     }
                 }
                 //add blog gallery if not added
                 $test = $GLOBALS['SITE_DB']->query_value_null_ok('galleries', 'name', array('name' => $row['autore'] . '_blog'));
                 if (is_null($test)) {
                     $rep_image = '';
                     //set default values for the watermark positions
                     $watermark_top_left = '';
                     $watermark_top_right = '';
                     $watermark_bottom_left = '';
                     $watermark_bottom_right = '';
                     if ($watermark_enable == 1 && strlen($watermark_image) > 0 && file_exists($watermark_image)) {
                         //$watermark_pos=2; //Possible values: 0 - Top-right; 1 - Center; 2 - Bottom-right (default for MKPortal)
                         if ($watermark_pos == 2) {
                             $watermark_top_right = $watermark_image;
                         } else {
                             $watermark_bottom_right = $watermark_image;
                         }
                     }
                     $add_date = $row['creato'];
                     ocf_over_msn();
                     add_gallery($row['autore'] . '_blog', $row['titolo'], html_to_comcode($row['descrizione']), '', '', $root_gallery, 1, 0, 0, 0, $rep_image, $watermark_top_left, $watermark_top_right, $watermark_bottom_left, $watermark_bottom_right, 1, 1, false, $add_date);
                     ocf_over_local();
                 }
                 $gal_idname = $row['autore'] . '_blog';
                 foreach ($blog_pimages as $blog_pimage) {
                     if (import_check_if_imported('blog_image', strval($blog_pimage['id']))) {
                         continue;
                     }
                     $submitter = $blog_pimage['iduser'];
                     ocf_over_msn();
                     //used to fixed the correct forum prefix
                     if (is_null($submitter)) {
                         $submitter = $GLOBALS['FORUM_DRIVER']->get_guest_id();
                     }
                     ocf_over_local();
                     //used to fixed the correct forum prefix
                     $id = get_param_integer('keep_preserve_ids', 0) == 0 ? NULL : $blog_pimage['id'];
                     $cat_name = $row['autore'] . '_blog';
                     ocf_over_msn();
                     $comment_text = $row['titolo'] . ' ' . html_to_comcode($row['descrizione']);
                     ocf_over_local();
                     //copy image and thumbnail and apply urls
                     $url = '';
                     $thumb_url = '';
                     //image source and destination
                     $save_filename = $old_base_dir . '/mkportal/blog/images/' . strval($blog_pimage['file']);
                     $copy_destination = $ocp_path . '/uploads/galleries/' . $blog_pimage['file'];
                     copy($save_filename, $copy_destination);
                     fix_permissions($copy_destination);
                     sync_file($copy_destination);
                     $url = get_custom_base_url() . '/uploads/galleries/' . $blog_pimage['file'];
                     $thumb_url = '';
                     $id_new = add_image('', $cat_name, $comment_text, $url, $url, $row['validate'], 1, 1, 1, '', $submitter, $row['creato'], $row['creato'], $row['click'], $id);
                     import_id_remap_put('blog_image', strval($blog_pimage['id']), $id_new);
                 }
             }
         }
         //end import blog images
     }
     //end blog import
     // Stories categories, story items, and comments
     $cats = $db->query('SELECT * FROM ' . $table_prefix . 'news_sections');
     $cat_id = array();
     $image = 'general';
     foreach ($cats as $cat) {
         $cat_id[$cat['id']] = $this->get_news_category_id($cat['titolo'], $image);
     }
     $pinned_news_cat_id = $this->get_news_category_id(do_lang('PINNED_NEWS'), $image);
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'news');
     foreach ($rows as $row) {
         if (import_check_if_imported('news', strval($row['id']))) {
             continue;
         }
         $topic = array_key_exists($row['idcategoria'], $cat_id) ? $cat_id[$row['idcategoria']] : db_get_first_id();
         $row['titolo'] = @html_entity_decode($row['titolo'], ENT_QUOTES, get_charset());
         ocf_over_msn();
         //used to fixed the correct forum prefix
         if ($row['pinned'] == 1) {
             $new_id = add_news($row['titolo'], '', $row['autore'], $row['validate'], 1, $com, 1, '', html_to_comcode($row['testo']), $topic, array($pinned_news_cat_id), $row['data'], $row['idautore']);
         } else {
             $new_id = add_news($row['titolo'], '', $row['autore'], $row['validate'], 1, $com, 1, '', html_to_comcode($row['testo']), $topic, array(), $row['data'], $row['idautore']);
         }
         ocf_over_local();
         //used to fixed the correct forum prefix
         import_id_remap_put('news', strval($row['id']), $new_id);
         // Comments
         $comments = $db->query('SELECT * FROM ' . $table_prefix . 'news_comments WHERE identry=' . strval($row['id']) . ' ORDER BY data');
         if (!is_null($forum_id)) {
             foreach ($comments as $comment) {
                 ocf_over_msn();
                 //used to fixed the correct forum prefix
                 $member = $GLOBALS['FORUM_DRIVER']->get_member_from_username($comment['autore']);
                 if (is_null($member)) {
                     $member = $GLOBALS['FORUM_DRIVER']->get_guest_id();
                 }
                 ocf_over_local();
                 //used to fixed the correct forum prefix
                 $title = '';
                 $post = $comment['testo'];
                 $content_url = build_url(array('page' => 'news', 'id' => $new_id, 'type' => 'view'), get_module_zone('news'));
                 ocf_over_msn();
                 //used to fixed the correct forum prefix
                 $GLOBALS['FORUM_DRIVER']->make_post_forum_topic($forum_name, 'news_' . strval($new_id), $member, $title, html_to_comcode($post), $row['titolo'], do_lang('COMMENT'), $content_url->evaluate());
                 ocf_over_local();
                 //used to fixed the correct forum prefix
             }
         }
     }
 }
Example #15
0
/**
 * Add a calendar event type.
 *
 * @param  SHORT_TEXT		The title of the event type
 * @param  ID_TEXT			The theme image code
 * @param  URLPATH			URL to external feed to associate with this event type
 * @return AUTO_LINK			The ID of the event type
 */
function add_event_type($title, $logo, $external_feed = '')
{
    $id = $GLOBALS['SITE_DB']->query_insert('calendar_types', array('t_title' => insert_lang($title, 2), 't_logo' => $logo, 't_external_feed' => $external_feed), true);
    log_it('ADD_EVENT_TYPE', strval($id), $title);
    return $id;
}
Example #16
0
 /**
  * Add a menu item from details in POST.
  *
  * @param  ID_TEXT		The name of the menu the item is on
  * @param  integer		The ID of the menu item (i.e. what it is referenced as in POST)
  * @param  array			The map of IDs on the menu (ID=>parent)
  * @param  ?integer		The ID of the parent branch (NULL: no parent)
  * @param  array			The map of menu id=>string language IDs employed by items before the edit
  * @param  integer		The order this branch has in the editor (and due to linearly moving through, the number of branches shown assembled ready)
  */
 function add_menu_item($menu, $id, &$ids, $parent, &$old_menu_bits, &$order)
 {
     // Load in details of menu item
     $caption = post_param('caption_' . strval($id), '');
     // Default needed to workaround Opera problem
     $caption_long = post_param('caption_long_' . strval($id), '');
     // Default needed to workaround Opera problem
     $page_only = post_param('match_tags_' . strval($id), '');
     // Default needed to workaround Opera problem
     $theme_img_code = post_param('theme_img_code_' . strval($id), '');
     // Default needed to workaround Opera problem
     $check_permissions = post_param_integer('check_perms_' . strval($id), 0);
     $branch_type = post_param('branch_type_' . strval($id), 'branch_plus');
     // Default needed to workaround Opera problem
     if ($branch_type == 'branch_plus') {
         $expanded = 1;
     } else {
         $expanded = 0;
     }
     $new_window = post_param_integer('new_window_' . strval($id), 0);
     /*		if ($branch_type=='page')
     		{*/
     $url = post_param('url_' . strval($id), '');
     // See if we can tidy it back to a page-link
     if (preg_match('#^\\w+$#', $url) != 0) {
         $url = ':' . $url;
     }
     // So users do not have to think about zones
     $page_link = url_to_pagelink($url, true);
     if ($page_link != '') {
         $url = $page_link;
     } elseif (strpos($url, ':') === false) {
         $url = fixup_protocolless_urls($url);
     }
     //		} else $url='';
     $menu_save_map = array('i_menu' => $menu, 'i_order' => $order, 'i_parent' => $parent, 'i_url' => $url, 'i_check_permissions' => $check_permissions, 'i_expanded' => $expanded, 'i_new_window' => $new_window, 'i_page_only' => $page_only, 'i_theme_img_code' => $theme_img_code);
     // Save
     if (array_key_exists($id, $old_menu_bits)) {
         $lang_code = $old_menu_bits[$id]['i_caption'];
         $lang_code_2 = $old_menu_bits[$id]['i_caption_long'];
         $menu_save_map += array('i_caption' => $lang_code, 'i_caption_long' => $lang_code_2);
         unset($old_menu_bits[$id]);
         $insert_id = $id;
         $GLOBALS['SITE_DB']->query_update('menu_items', $menu_save_map, array('id' => $id));
         lang_remap($lang_code, $caption);
         lang_remap($lang_code_2, $caption_long);
     } else {
         $lang_code = insert_lang($caption, 1);
         $lang_code_2 = insert_lang($caption_long, 1);
         $menu_save_map += array('i_caption' => $lang_code, 'i_caption_long' => $lang_code_2);
         $insert_id = $GLOBALS['SITE_DB']->query_insert('menu_items', $menu_save_map, true);
     }
     // Menu item children
     $my_kids = array();
     foreach ($ids as $new_id => $child_parent) {
         if (strval($id) == $child_parent) {
             $my_kids[] = $new_id;
         }
     }
     foreach ($my_kids as $new_id) {
         $this->add_menu_item($menu, $new_id, $ids, $insert_id, $old_menu_bits, $order);
         $order++;
     }
 }
Example #17
0
 /**
  * Load Comcode page from disk, then cache it.
  *
  * @param  PATH			The relative (to ocPortal's base directory) path to the page (e.g. pages/comcode/EN/start.txt)
  * @param  ID_TEXT		The zone the page is being loaded from
  * @param  ID_TEXT		The codename of the page
  * @param  PATH			The file base to load from
  * @param  ?array			Row from database (holds submitter etc) (NULL: no row, originated first from disk)
  * @param  array			New row for database, used if necessary (holds submitter etc)
  * @param  boolean		Whether the page is being included from another
  * @return array			A triple: The page, Title to use, New Comcode page row
  */
 function _load_comcode_page_not_cached($string, $zone, $codename, $file_base, $comcode_page_row, $new_comcode_page_row, $being_included = false)
 {
     global $COMCODE_PARSE_TITLE;
     $nql_backup = $GLOBALS['NO_QUERY_LIMIT'];
     $GLOBALS['NO_QUERY_LIMIT'] = true;
     // Not cached :(
     $result = file_get_contents($file_base . '/' . $string, FILE_TEXT);
     $non_trans_result = $result;
     if (strpos($string, '/' . get_site_default_lang() . '/') !== false && user_lang() != get_site_default_lang()) {
         $result = google_translate($result, user_lang());
     }
     if (is_null($new_comcode_page_row['p_submitter'])) {
         $as_admin = true;
         $members = $GLOBALS['FORUM_DRIVER']->member_group_query($GLOBALS['FORUM_DRIVER']->get_super_admin_groups(), 1);
         if (count($members) != 0) {
             $new_comcode_page_row['p_submitter'] = $GLOBALS['FORUM_DRIVER']->pname_id($members[key($members)]);
         } else {
             $new_comcode_page_row['p_submitter'] = db_get_first_id() + 1;
             // On OCF and most forums, this is the first admin member
         }
     }
     if (is_null($comcode_page_row)) {
         $page_submitter = $new_comcode_page_row['p_submitter'];
     } else {
         $as_admin = false;
         // Will only have admin privileges if $page_submitter has them
         $page_submitter = $comcode_page_row['p_submitter'];
     }
     // Parse and work out how to add
     $lang = user_lang();
     global $LAX_COMCODE;
     $temp = $LAX_COMCODE;
     $LAX_COMCODE = true;
     $_text2 = comcode_to_tempcode($result, $page_submitter, $as_admin, 60, $being_included || strpos($codename, 'panel_') !== false ? 'panel' : NULL);
     $text2 = $_text2->to_assembly();
     if (get_site_default_lang() != $lang) {
         $non_trans__text2 = comcode_to_tempcode($non_trans_result, $page_submitter, $as_admin, 60, $being_included || strpos($codename, 'panel_') !== false ? 'panel' : NULL);
         $non_trans_text2 = $non_trans__text2->to_assembly();
     }
     $LAX_COMCODE = $temp;
     // Check it still needs inserting (it might actually be there, but not translated)
     $trans_key = $GLOBALS['SITE_DB']->query_value_null_ok('cached_comcode_pages', 'string_index', array('the_page' => $codename, 'the_zone' => $zone, 'the_theme' => $GLOBALS['FORUM_DRIVER']->get_theme()));
     if (is_null($COMCODE_PARSE_TITLE)) {
         $COMCODE_PARSE_TITLE = '';
     }
     $title_to_use = clean_html_title($COMCODE_PARSE_TITLE);
     if (!is_null($trans_key)) {
         $_comcode_page_row = $GLOBALS['SITE_DB']->query_select('comcode_pages', array('*'), array('the_zone' => $zone, 'the_page' => $codename), '', 1);
         if (!array_key_exists(0, $_comcode_page_row)) {
             $trans_key = NULL;
             $GLOBALS['SITE_DB']->query_delete('cached_comcode_pages', array('the_zone' => $zone, 'the_page' => $codename, 'the_theme' => $GLOBALS['FORUM_DRIVER']->get_theme()));
         }
     }
     if (is_null($trans_key)) {
         $index = $GLOBALS['SITE_DB']->query_insert('translate', array('source_user' => $page_submitter, 'broken' => 0, 'importance_level' => 1, 'text_original' => $result, 'text_parsed' => $text2, 'language' => $lang), true, false, true);
         if (get_site_default_lang() != $lang) {
             $GLOBALS['SITE_DB']->query_insert('translate', array('id' => $index, 'source_user' => $page_submitter, 'broken' => 0, 'importance_level' => 1, 'text_original' => $non_trans_result, 'text_parsed' => $non_trans_text2, 'language' => get_site_default_lang()), true, false, true);
         }
         $GLOBALS['SITE_DB']->query_insert('cached_comcode_pages', array('the_zone' => $zone, 'the_page' => $codename, 'string_index' => $index, 'the_theme' => $GLOBALS['FORUM_DRIVER']->get_theme(), 'cc_page_title' => insert_lang(clean_html_title($COMCODE_PARSE_TITLE), 1, NULL, false, NULL, NULL, false, NULL, NULL, 60, true, true)), false, true);
         // Race conditions
         decache('main_comcode_page_children');
         // Try and insert corresponding page; will silently fail if already exists. This is only going to add a row for a page that was not created in-system
         if (is_null($comcode_page_row)) {
             $comcode_page_row = $new_comcode_page_row;
             $GLOBALS['SITE_DB']->query_insert('comcode_pages', $comcode_page_row, false, true);
         }
     } else {
         $comcode_page_row = $_comcode_page_row[0];
         // Check to see if it needs translating
         $test = $GLOBALS['SITE_DB']->query_value_null_ok('translate', 'id', array('id' => $trans_key, 'language' => $lang));
         if (is_null($test)) {
             $GLOBALS['SITE_DB']->query_insert('translate', array('id' => $trans_key, 'source_user' => $page_submitter, 'broken' => 0, 'importance_level' => 1, 'text_original' => $result, 'text_parsed' => $text2, 'language' => $lang));
             $index = $trans_key;
         }
     }
     $GLOBALS['NO_QUERY_LIMIT'] = $nql_backup;
     return array($_text2, $title_to_use, $comcode_page_row);
 }
Example #18
0
/**
 * If a text field has picked up Comcode support, we will need to run this.
 *
 * @param  object			Link to the real database object
 * @param  ID_TEXT		The table name
 * @param  ID_TEXT		The field name
 * @param  ID_TEXT		The tables key field name
 * @param  integer		The translation level to use
 * @set    1 2 3 4
 * @param  boolean		Whether our data is already stored in Tempcode assembly format
 */
function _helper_promote_text_field_to_comcode($this_ref, $table_name, $name, $key = 'id', $level = 2, $in_assembly = false)
{
    $rows = $this_ref->query_select($table_name, array($name, $key));
    $this_ref->delete_table_field($table_name, $name);
    $this_ref->add_table_field($table_name, $name, 'SHORT_TRANS');
    foreach ($rows as $row) {
        if ($in_assembly) {
            $turned = insert_lang('', $level, $this_ref, true, NULL, NULL, false, NULL, $row[$name]);
            $this_ref->query_update($table_name, array($name => $turned), array($key => $row[$key]));
        } else {
            $this_ref->query_update($table_name, array($name => insert_lang($row[$name], $level, $this_ref)), array($key => $row[$key]));
        }
    }
    if (function_exists('persistant_cache_set')) {
        persistant_cache_delete('TABLE_LANG_FIELDS');
    }
}
Example #19
0
 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  */
 function import_contacts($db, $table_prefix, $old_base_dir)
 {
     require_code('catalogues2');
     require_code('catalogues');
     // Add contacts catalogue if it doesn't already exist
     $test = $GLOBALS['SITE_DB']->query_value_null_ok('catalogues', 'c_name', array('c_name' => 'contacts'));
     if (is_null($test)) {
         actual_add_catalogue('contacts', lang_code_to_default_content('CONTACTS', false, 2), insert_lang('', 2), 0, 0, '', 30);
         $fields = array(array('CONTACT_FIRST_NAME', '', 'short_text', 0, 1), array('CONTACT_LAST_NAME', '', 'short_text', 1, 1), array('EMAIL_ADDRESS', '', 'short_text', 0, 1), array('CONTACT_COMPANY', '', 'short_text', 0, 1), array('CONTACT_HOMEADDRESS', '', 'short_text', 0, 1), array('CONTACT_CITY', '', 'short_text', 0, 1), array('CONTACT_HOMEPHONE', '', 'short_text', 0, 1), array('CONTACT_WORKPHONE', '', 'short_text', 0, 1), array('CONTACT_HOMEPAGE', '', 'short_text', 0, 1), array('CONTACT_IM', '', 'short_text', 0, 1), array('CONTACT_EVENTS', '', 'long_text', 0, 1), array('CONTACT_NOTES', '', 'long_text', 0, 1));
         foreach ($fields as $i => $field) {
             actual_add_catalogue_field('contacts', lang_code_to_default_content($field[0], false, 3), insert_lang('', 2), $field[2], $i, $field[3], 1, 1, '', $field[4]);
         }
     }
     $id = actual_add_catalogue_category('contacts', 'ex-phpNuke', '', '', NULL, '');
     $fields = collapse_1d_complexity('id', $GLOBALS['SITE_DB']->query_select('catalogue_fields', array('id'), array('c_name' => 'contacts')));
     $contacts = $db->query('SELECT * FROM ' . $table_prefix . 'contactbook');
     foreach ($contacts as $row) {
         $map = array($fields[0] => $row['firstname'], $fields[1] => $row['lastname'], $fields[2] => $row['email'], $fields[3] => $row['company'], $fields[4] => $row['homeaddress'], $fields[5] => $row['city'], $fields[6] => $row['homephone'], $fields[7] => $row['workphone'], $fields[8] => $row['homepage'], $fields[9] => $row['IM'], $fields[10] => $row['events'], $fields[11] => $row['notes']);
         actual_add_catalogue_entry($id, 1, '', 0, 0, 0, $map);
     }
 }
Example #20
0
/**
 * Adds a news entry to the database, and send out the news to any RSS cloud listeners.
 *
 * @param  SHORT_TEXT		The news title
 * @param  LONG_TEXT			The news summary (or if not an article, the full news)
 * @param  ?ID_TEXT			The news author (possibly, a link to an existing author in the system, but does not need to be) (NULL: current username)
 * @param  BINARY				Whether the news has been validated
 * @param  BINARY				Whether the news may be rated
 * @param  SHORT_INTEGER	Whether comments are allowed (0=no, 1=yes, 2=review style)
 * @param  BINARY				Whether the news may have trackbacks
 * @param  LONG_TEXT			Notes for the news
 * @param  LONG_TEXT			The news entry (blank means no entry)
 * @param  ?AUTO_LINK		The primary news category (NULL: personal)
 * @param  ?array				The IDs of the news categories that this is in (NULL: none)
 * @param  ?TIME				The time of submission (NULL: now)
 * @param  ?MEMBER			The news submitter (NULL: current member)
 * @param  integer			The number of views the article has had
 * @param  ?TIME				The edit date (NULL: never)
 * @param  ?AUTO_LINK		Force an ID (NULL: don't force an ID)
 * @param  URLPATH			URL to the image for the news entry (blank: use cat image)
 * @return AUTO_LINK			The ID of the news just added
 */
function add_news($title, $news, $author = NULL, $validated = 1, $allow_rating = 1, $allow_comments = 1, $allow_trackbacks = 1, $notes = '', $news_article = '', $main_news_category = NULL, $news_category = NULL, $time = NULL, $submitter = NULL, $views = 0, $edit_date = NULL, $id = NULL, $image = '')
{
    if (is_null($author)) {
        $author = $GLOBALS['FORUM_DRIVER']->get_username(get_member());
    }
    if (is_null($news_category)) {
        $news_category = array();
    }
    if (is_null($time)) {
        $time = time();
    }
    if (is_null($submitter)) {
        $submitter = get_member();
    }
    $already_created_personal_category = false;
    require_code('comcode_check');
    check_comcode($news_article, NULL, false, NULL, true);
    if (is_null($main_news_category)) {
        $main_news_category_id = $GLOBALS['SITE_DB']->query_value_null_ok('news_categories', 'id', array('nc_owner' => $submitter));
        if (is_null($main_news_category_id)) {
            if (!has_specific_permission(get_member(), 'have_personal_category', 'cms_news')) {
                fatal_exit(do_lang_tempcode('INTERNAL_ERROR'));
            }
            $p_nc_title = insert_lang(do_lang('MEMBER_CATEGORY', $GLOBALS['FORUM_DRIVER']->get_username($submitter)), 2);
            $main_news_category_id = $GLOBALS['SITE_DB']->query_insert('news_categories', array('nc_title' => $p_nc_title, 'nc_img' => 'newscats/community', 'notes' => '', 'nc_owner' => $submitter), true);
            $already_created_personal_category = true;
            $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true);
            foreach (array_keys($groups) as $group_id) {
                $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'news', 'category_name' => strval($main_news_category_id), 'group_id' => $group_id));
            }
        }
    } else {
        $main_news_category_id = $main_news_category;
    }
    if (!addon_installed('unvalidated')) {
        $validated = 1;
    }
    $map = array('news_image' => $image, 'edit_date' => $edit_date, 'news_category' => $main_news_category_id, 'news_views' => $views, 'news_article' => 0, 'allow_rating' => $allow_rating, 'allow_comments' => $allow_comments, 'allow_trackbacks' => $allow_trackbacks, 'notes' => $notes, 'submitter' => $submitter, 'validated' => $validated, 'date_and_time' => $time, 'title' => insert_lang_comcode($title, 1), 'news' => insert_lang_comcode($news, 1), 'author' => $author);
    if (!is_null($id)) {
        $map['id'] = $id;
    }
    $id = $GLOBALS['SITE_DB']->query_insert('news', $map, true);
    if (!is_null($news_category)) {
        $news_category = array_unique($news_category);
        foreach ($news_category as $value) {
            if (is_null($value) && !$already_created_personal_category) {
                $p_nc_title = insert_lang(do_lang('MEMBER_CATEGORY', $GLOBALS['FORUM_DRIVER']->get_username($submitter)), 2);
                $news_category_id = $GLOBALS['SITE_DB']->query_insert('news_categories', array('nc_title' => $p_nc_title, 'nc_img' => 'newscats/community', 'notes' => '', 'nc_owner' => $submitter), true);
                $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true);
                foreach (array_keys($groups) as $group_id) {
                    $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'news', 'category_name' => strval($news_category_id), 'group_id' => $group_id));
                }
            } else {
                $news_category_id = $value;
            }
            if (is_null($news_category_id)) {
                continue;
            }
            // Double selected
            $GLOBALS['SITE_DB']->query_insert('news_category_entries', array('news_entry' => $id, 'news_entry_category' => $news_category_id));
        }
    }
    require_code('attachments2');
    $map = array('news_article' => insert_lang_comcode_attachments(2, $news_article, 'news', strval($id)));
    $GLOBALS['SITE_DB']->query_update('news', $map, array('id' => $id), '', 1);
    log_it('ADD_NEWS', strval($id), $title);
    if (function_exists('xmlrpc_encode')) {
        if (function_exists('set_time_limit')) {
            @set_time_limit(0);
        }
        // Send out on RSS cloud
        $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'news_rss_cloud WHERE register_time<' . strval(time() - 25 * 60 * 60));
        $start = 0;
        do {
            $listeners = $GLOBALS['SITE_DB']->query_select('news_rss_cloud', array('*'), NULL, '', 100, $start);
            foreach ($listeners as $listener) {
                $data = $listener['watching_channel'];
                if ($listener['rem_protocol'] == 'xml-rpc') {
                    $request = xmlrpc_encode_request($listener['rem_procedure'], $data);
                    $length = strlen($request);
                    $_length = strval($length);
                    $packet = <<<END
POST /{$listener['rem_path']} HTTP/1.0
Host: {$listener['rem_ip']}
Content-Type: text/xml
Content-length: {$_length}

{$request}
END;
                }
                $errno = 0;
                $errstr = '';
                $mysock = @fsockopen($listener['rem_ip'], $listener['rem_port'], $errno, $errstr, 6.0);
                if ($mysock !== false) {
                    @fwrite($mysock, $packet);
                    @fclose($mysock);
                }
                $start += 100;
            }
        } while (array_key_exists(0, $listeners));
    }
    require_code('seo2');
    seo_meta_set_for_implicit('news', strval($id), array($title, $news == '' ? $news_article : $news), $news == '' ? $news_article : $news);
    // News article could be used, but it's probably better to go for the summary only to avoid crap
    if ($validated == 1) {
        decache('main_news');
        decache('side_news');
        decache('side_news_archive');
        decache('bottom_news');
        dispatch_news_notification($id, $title, $main_news_category_id);
    }
    if ($validated == 1 && get_option('site_closed') == '0' && ocp_srv('HTTP_HOST') != '127.0.0.1' && ocp_srv('HTTP_HOST') != 'localhost' && has_category_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'news', strval($main_news_category_id))) {
        $_ping_url = str_replace('{url}', urlencode(get_base_url()), str_replace('{rss}', urlencode(find_script('backend') . '?type=rss&mode=news'), str_replace('{title}', urlencode(get_site_name()), get_option('ping_url'))));
        $ping_urls = explode(chr(10), $_ping_url);
        foreach ($ping_urls as $ping_url) {
            $ping_url = trim($ping_url);
            if ($ping_url != '') {
                http_download_file($ping_url, NULL, false);
            }
        }
    }
    return $id;
}
Example #21
0
 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  */
 function import_ocf_members($db, $table_prefix, $file_base)
 {
     if ($this->on_same_msn($file_base)) {
         return;
     }
     $cpf_types = collapse_2d_complexity('id', 'cf_type', $GLOBALS['FORUM_DB']->query_select('f_custom_fields', array('id', 'cf_type')));
     $row_start = 0;
     $rows = array();
     do {
         $rows = $db->query('SELECT * FROM ' . $table_prefix . 'f_members ORDER BY id', 200, $row_start);
         foreach ($rows as $row) {
             if (import_check_if_imported('member', strval($row['id']))) {
                 continue;
             }
             $test = $GLOBALS['OCF_DRIVER']->get_member_from_username($row['m_username']);
             if (!is_null($test)) {
                 // Fix usergroup leadership
                 $GLOBALS['FORUM_DB']->query_update('f_groups', array('g_group_leader' => $test), array('g_group_leader' => -$row['id']));
                 import_id_remap_put('member', strval($row['id']), $test);
                 continue;
             }
             $primary_group = import_id_remap_get('group', strval($row['m_primary_group']));
             $custom_fields = array();
             $id = get_param_integer('keep_preserve_ids', 0) == 0 ? NULL : $row['id'];
             $timezone = $row['m_timezone_offset'];
             if (is_integer($timezone)) {
                 $timezone = strval($timezone);
             }
             if (!isset($row['m_auto_monitor_contrib_content'])) {
                 $row['m_auto_monitor_contrib_content'] = $row['m_track_contributed_topics'];
             }
             $id_new = ocf_make_member($row['m_username'], $row['m_pass_hash_salted'], $row['m_email_address'], NULL, $row['m_dob_day'], $row['m_dob_month'], $row['m_dob_year'], $custom_fields, $timezone, $primary_group, $row['m_validated'], $row['m_join_time'], $row['m_last_visit_time'], $row['m_theme'], $row['m_avatar_url'], $this->get_lang_string($db, $row['m_signature']), $row['m_is_perm_banned'], $row['m_preview_posts'], $row['m_reveal_age'], $row['m_title'], $row['m_photo_url'], $row['m_photo_thumb_url'], $row['m_views_signatures'], $row['m_auto_monitor_contrib_content'], $row['m_language'], $row['m_allow_emails'], array_key_exists('m_allow_emails_from_staff', $row) ? $row['m_allow_emails_from_staff'] : $row['m_allow_emails'], $row['m_notes'], $row['m_ip_address'], $row['m_validated_email_confirm_code'], false, array_key_exists('m_password_compat_scheme', $row) ? $row['m_password_compat_scheme'] : $row['m_password_compatibility_scheme'], $row['m_pass_salt'], $row['m_zone_wide'], $row['m_last_submit_time'], $id, array_key_exists('m_highlighted_name', $row) ? $row['m_highlighted_name'] : 0, array_key_exists('m_pt_allow', $row) ? $row['m_pt_allow'] : '*', array_key_exists('m_pt_rules_text', $row) ? $this->get_lang_string($db, $row['m_pt_rules_text']) : '');
             $rows2 = $db->query('SELECT * FROM ' . $table_prefix . 'f_member_custom_fields WHERE mf_member_id=' . strval((int) $row['id']), 1);
             if (array_key_exists(0, $rows2)) {
                 $row2 = array();
                 foreach ($rows2[0] as $key => $val) {
                     if (is_null($val)) {
                         $val = '';
                     }
                     if (substr($key, 0, 6) == 'field_') {
                         $cpf_id = import_id_remap_get('cpf', substr($key, 6), true);
                         if (is_null($cpf_id)) {
                             continue;
                         }
                         $cpf_type = $cpf_types[$cpf_id];
                         if ($cpf_type == 'short_trans' || $cpf_type == 'long_trans') {
                             $val = strval(insert_lang($this->get_lang_string($db, intval($val)), 3));
                         }
                         $row2['field_' . strval($cpf_id)] = $val;
                     }
                 }
                 $GLOBALS['SITE_DB']->query_update('f_member_custom_fields', $row2, array('mf_member_id' => $id_new), '', 1);
             }
             // Fix some tricky dependences that we shoved to one side
             $GLOBALS['FORUM_DB']->query_update('f_groups', array('g_group_leader' => $id_new), array('g_group_leader' => -$row['id']));
             $GLOBALS['SITE_DB']->query_update('attachments', array('a_member_id' => $id_new), array('a_member_id' => -$row['id']));
             import_id_remap_put('member', strval($row['id']), $id_new);
         }
         $row_start += 200;
     } while (count($rows) > 0);
     // Group membership
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'f_group_members');
     foreach ($rows as $row) {
         $row['gm_group_id'] = import_id_remap_get('group', strval($row['gm_group_id']), true);
         if (is_null($row['gm_group_id'])) {
             continue;
         }
         $row['gm_member_id'] = import_id_remap_get('member', strval($row['gm_member_id']), true);
         if (is_null($row['gm_member_id'])) {
             continue;
         }
         $GLOBALS['SITE_DB']->query_insert('f_group_members', $row, false, true);
     }
     // Known login IPs
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'f_member_known_login_ips');
     foreach ($rows as $row) {
         $row['i_member_id'] = import_id_remap_get('member', strval($row['i_member_id']), true);
         if (is_null($row['i_member_id'])) {
             continue;
         }
         $GLOBALS['SITE_DB']->query_insert('f_member_known_login_ips', $row);
     }
     // Group member timeouts
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'f_group_member_timeouts');
     foreach ($rows as $row) {
         $member_id = import_id_remap_get('member', strval($row['member_id']));
         if (is_null($member_id)) {
             continue;
         }
         $group_id = import_id_remap_get('group', strval($row['group_id']));
         if (is_null($group_id)) {
             continue;
         }
         $GLOBALS['SITE_DB']->query_insert('f_group_member_timeouts', array('member_id' => $member_id, 'group_id' => $group_id, 'timeout' => $row['timeout']));
     }
     // Invites
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'f_invites ORDER BY id', NULL, NULL, true);
     if (!is_null($rows)) {
         foreach ($rows as $row) {
             $i_inviter = import_id_remap_get('member', strval($row['i_inviter']), true);
             if (is_null($i_inviter)) {
                 continue;
             }
             $GLOBALS['SITE_DB']->query_insert('f_invites', array('i_inviter' => $i_inviter, 'i_email_address' => $row['i_email_address'], 'i_time' => $row['i_time'], 'i_taken' => $row['i_taken']), false, true);
         }
     }
 }
Example #22
0
/**
 * Add a download.
 *
 * @param  AUTO_LINK			The ID of the category the download is to be in
 * @param  SHORT_TEXT		The name of the download
 * @param  URLPATH			The URL to the download
 * @param  LONG_TEXT			The description of the download
 * @param  ID_TEXT			The author of the download (not necessarily same as the submitter)
 * @param  LONG_TEXT			The comments for the download
 * @param  ?AUTO_LINK		The out-mode-id (the ID of a download that this download is an old version of). Often people wonder why this is specified with the old version, and not the opposite with the new version - it is because statistically, we perceive more chance of downloads merging than splitting (NULL: none)
 * @param  BINARY				Whether the download has been validated
 * @param  BINARY				Whether the download may be rated
 * @param  SHORT_INTEGER	Whether comments are allowed (0=no, 1=yes, 2=review style)
 * @param  BINARY				Whether the download may be trackbacked
 * @param  LONG_TEXT			Hidden notes pertaining to the download
 * @param  SHORT_TEXT		The downloads original filename (the URL may be obfuscated)
 * @param  integer			The file size of the download (we can't really detect this in real-time for remote URLs)
 * @param  integer			The cost of the download that members will have to pay to get it
 * @param  BINARY				Whether the submitter gets the points for the download (they are selling it) (otherwise they are just thrown out, which is an alternative model - one of enforcing community point building)
 * @param  ?AUTO_LINK		The licence to use (NULL: none)
 * @param  ?TIME				The add date for the download (NULL: now)
 * @param  integer			The number of downloads that this download has had
 * @param  integer			The number of views that this download has had
 * @param  ?MEMBER			The submitter (NULL: current user)
 * @param  ?TIME				The edit date (NULL: never)
 * @param  ?AUTO_LINK		Force an ID (NULL: don't force an ID)
 * @return AUTO_LINK			The ID of the newly added download
 */
function add_download($category_id, $name, $url, $description, $author, $comments, $out_mode_id, $validated, $allow_rating, $allow_comments, $allow_trackbacks, $notes, $original_filename, $file_size, $cost, $submitter_gets_points, $licence = NULL, $add_date = NULL, $num_downloads = 0, $views = 0, $submitter = NULL, $edit_date = NULL, $id = NULL)
{
    if (is_null($add_date)) {
        $add_date = time();
    }
    if (is_null($submitter)) {
        $submitter = get_member();
    }
    if ($file_size == 0 || url_is_local($url)) {
        if (url_is_local($url)) {
            $file_size = @filesize(get_custom_file_base() . '/' . rawurldecode($url)) or $file_size = NULL;
        } else {
            $file_size = @filesize($url) or $file_size = NULL;
        }
    }
    $met = @ini_get('max_execution_time');
    $data_mash = $url == '' ? '' : create_data_mash($url, NULL, get_file_extension($original_filename));
    if (function_exists('set_time_limit')) {
        @set_time_limit($met);
    }
    if (!addon_installed('unvalidated')) {
        $validated = 1;
    }
    $map = array('download_data_mash' => $data_mash, 'download_licence' => $licence, 'rep_image' => '', 'edit_date' => $edit_date, 'download_submitter_gets_points' => $submitter_gets_points, 'download_cost' => $cost, 'original_filename' => $original_filename, 'download_views' => $views, 'allow_rating' => $allow_rating, 'allow_comments' => $allow_comments, 'allow_trackbacks' => $allow_trackbacks, 'notes' => $notes, 'submitter' => $submitter, 'default_pic' => 1, 'num_downloads' => $num_downloads, 'out_mode_id' => $out_mode_id, 'category_id' => $category_id, 'name' => insert_lang($name, 2), 'url' => $url, 'description' => insert_lang_comcode($description, 3), 'author' => $author, 'comments' => insert_lang_comcode($comments, 3), 'validated' => $validated, 'add_date' => $add_date, 'file_size' => $file_size);
    if (!is_null($id)) {
        $map['id'] = $id;
    }
    $id = $GLOBALS['SITE_DB']->query_insert('download_downloads', $map, true);
    require_code('seo2');
    seo_meta_set_for_implicit('downloads_download', strval($id), array($name, $description, $comments), $description);
    // Make its gallery
    if (addon_installed('galleries') && !running_script('stress_test_loader')) {
        $test = $GLOBALS['SITE_DB']->query_value_null_ok('galleries', 'name', array('name' => 'download_' . strval($id)));
        if (is_null($test)) {
            require_code('galleries2');
            $download_gallery_root = get_option('download_gallery_root');
            if (is_null($download_gallery_root)) {
                $download_gallery_root = 'root';
            }
            add_gallery('download_' . strval($id), do_lang('GALLERY_FOR_DOWNLOAD', $name), '', '', '', $download_gallery_root);
        }
    }
    // Stat
    update_stat('num_archive_downloads', 1);
    if ($file_size > 0) {
        update_stat('archive_size', $file_size);
    }
    if ($validated == 1) {
        require_lang('downloads');
        require_code('notifications');
        $subject = do_lang('DOWNLOAD_NOTIFICATION_MAIL_SUBJECT', get_site_name(), $name);
        $self_url = build_url(array('page' => 'downloads', 'type' => 'entry', 'id' => $id), get_module_zone('downloads'), NULL, false, false, true);
        $mail = do_lang('DOWNLOAD_NOTIFICATION_MAIL', comcode_escape(get_site_name()), comcode_escape($name), array(comcode_escape($self_url->evaluate())));
        dispatch_notification('download', strval($category_id), $subject, $mail);
    }
    log_it('ADD_DOWNLOAD', strval($id), $name);
    decache('main_recent_downloads');
    decache('main_top_downloads');
    decache('main_download_category');
    decache('main_download_tease');
    return $id;
}
Example #23
0
/**
 * Make a Welcome E-mail.
 *
 * @param  SHORT_TEXT	A name for the Welcome E-mail
 * @param  SHORT_TEXT	The subject of the Welcome E-mail
 * @param  LONG_TEXT		The message body of the Welcome E-mail
 * @param  integer		The number of hours before sending the e-mail
 * @param  ?AUTO_LINK	What newsletter to send out to instead of members (NULL: none)
 * @return AUTO_LINK		The ID
 */
function ocf_make_welcome_email($name, $subject, $text, $send_time, $newsletter = 0)
{
    $id = $GLOBALS['SITE_DB']->query_insert('f_welcome_emails', array('w_name' => $name, 'w_newsletter' => $newsletter, 'w_subject' => insert_lang($subject, 2), 'w_text' => insert_lang($text, 2), 'w_send_time' => $send_time), true);
    log_it('ADD_WELCOME_EMAIL', strval($id), $subject);
    return $id;
}
Example #24
0
/**
 * Make a custom profile field.
 *
 * @param  SHORT_TEXT	Name of the field.
 * @param  BINARY			Whether the field is locked (i.e. cannot be deleted from the system).
 * @param  SHORT_TEXT 	Description of the field.
 * @param  LONG_TEXT  	The default value for the field.
 * @param  BINARY			Whether the field is publicly viewable.
 * @param  BINARY			Whether the field is viewable by the owner.
 * @param  BINARY			Whether the field may be set by the owner.
 * @param  BINARY			Whether the field is encrypted.
 * @param  ID_TEXT		The type of the field.
 * @set    short_text long_text short_trans long_trans integer upload picture url list tick float
 * @param  BINARY			Whether it is required that every member have this field filled in.
 * @param  BINARY			Whether this field is shown in posts and places where member details are highlighted (such as an image in a member gallery).
 * @param  BINARY			Whether this field is shown in preview places, such as in the teaser for a member gallery.
 * @param  ?integer		The order of this field relative to other fields (NULL: next).
 * @param  LONG_TEXT 	The usergroups that this field is confined to (comma-separated list).
 * @param  boolean		Whether to check that no field has this name already.
 * @param  BINARY			Whether the field is to be shown on the join form
 * @return AUTO_LINK  	The ID of the new custom profile field.
 */
function ocf_make_custom_field($name, $locked = 0, $description = '', $default = '', $public_view = 0, $owner_view = 0, $owner_set = 0, $encrypted = 0, $type = 'long_text', $required = 0, $show_in_posts = 0, $show_in_post_previews = 0, $order = NULL, $only_group = '', $no_name_dupe = false, $show_on_join_form = 0)
{
    $dbs_back = $GLOBALS['NO_DB_SCOPE_CHECK'];
    $GLOBALS['NO_DB_SCOPE_CHECK'] = true;
    if ($only_group == '-1') {
        $only_group = '';
    }
    // Can only encrypt things if encryption support is available
    require_code('encryption');
    //if (!is_encryption_enabled()) $encrypted=0;
    // Can't have publicly-viewable encrypted fields
    if ($encrypted == 1) {
        $public_view = 0;
    }
    if ($no_name_dupe) {
        $test = $GLOBALS['FORUM_DB']->query_value_null_ok('f_custom_fields f LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON f.cf_name=t.id', 'f.id', array('text_original' => $name));
        if (!is_null($test)) {
            $GLOBALS['NO_DB_SCOPE_CHECK'] = $dbs_back;
            return $test;
        }
    }
    if (is_null($order)) {
        $order = $GLOBALS['FORUM_DB']->query_value('f_custom_fields', 'MAX(cf_order)');
        if (is_null($order)) {
            $order = 0;
        } else {
            $order++;
        }
    }
    $map = array('cf_name' => insert_lang($name, 2, $GLOBALS['FORUM_DB']), 'cf_locked' => $locked, 'cf_description' => insert_lang($description, 2, $GLOBALS['FORUM_DB']), 'cf_default' => $default, 'cf_public_view' => $public_view, 'cf_owner_view' => $owner_view, 'cf_owner_set' => $owner_set, 'cf_type' => $type, 'cf_required' => $required, 'cf_show_in_posts' => $show_in_posts, 'cf_show_in_post_previews' => $show_in_post_previews, 'cf_order' => $order, 'cf_only_group' => $only_group, 'cf_show_on_join_form' => $show_on_join_form);
    $id = $GLOBALS['FORUM_DB']->query_insert('f_custom_fields', $map + array('cf_encrypted' => $encrypted), true, true);
    if (is_null($id)) {
        $id = $GLOBALS['FORUM_DB']->query_insert('f_custom_fields', $map, true);
    }
    // Still upgrading, cf_encrypted does not exist yet
    list($_type, $index) = get_cpf_storage_for($type);
    require_code('database_action');
    // ($index?'#':'').
    $GLOBALS['FORUM_DB']->add_table_field('f_member_custom_fields', 'field_' . strval($id), $_type);
    // Default will be made explicit when we insert rows
    $indices_count = $GLOBALS['FORUM_DB']->query_value('db_meta_indices', 'COUNT(*)', array('i_table' => 'f_member_custom_fields'));
    if ($indices_count < 60) {
        if ($index) {
            if ($_type != 'LONG_TEXT') {
                $GLOBALS['FORUM_DB']->create_index('f_member_custom_fields', 'mcf' . strval($id), array('field_' . strval($id)), 'mf_member_id');
            }
            if (strpos($_type, '_TEXT') !== false) {
                $GLOBALS['FORUM_DB']->create_index('f_member_custom_fields', '#mcf_ft_' . strval($id), array('field_' . strval($id)), 'mf_member_id');
            }
        } elseif (strpos($type, 'trans') !== false || $type == 'posting_field') {
            $GLOBALS['FORUM_DB']->create_index('f_member_custom_fields', 'mcf' . strval($id), array('field_' . strval($id)), 'mf_member_id');
            // For joins
        }
    }
    log_it('ADD_CUSTOM_PROFILE_FIELD', strval($id), $name);
    $GLOBALS['NO_DB_SCOPE_CHECK'] = $dbs_back;
    return $id;
}
Example #25
0
/**
 * Add a CEDI page
 *
 * @param  SHORT_TEXT	The page title
 * @param  LONG_TEXT		The page description
 * @param  LONG_TEXT		Hidden notes pertaining to the page
 * @param  BINARY			Whether to hide the posts on the page by default
 * @param  ?MEMBER		The member doing the action (NULL: current member)
 * @return AUTO_LINK		The page ID
 */
function cedi_add_page($title, $description, $notes, $hide_posts, $member = NULL)
{
    if (is_null($member)) {
        $member = get_member();
    }
    require_code('comcode_check');
    check_comcode($description, NULL, false, NULL, true);
    if ($description != '') {
        $id = $GLOBALS['SITE_DB']->query_insert('seedy_pages', array('submitter' => $member, 'hide_posts' => $hide_posts, 'seedy_views' => 0, 'notes' => $notes, 'description' => 0, 'title' => insert_lang($title, 2), 'add_date' => time()), true);
        require_code('attachments2');
        $GLOBALS['SITE_DB']->query_update('seedy_pages', array('description' => insert_lang_comcode_attachments(2, $description, 'cedi_page', strval($id), NULL, false, $member)), array('id' => $id), '', 1);
    } else {
        $id = $GLOBALS['SITE_DB']->query_insert('seedy_pages', array('submitter' => $member, 'hide_posts' => $hide_posts, 'seedy_views' => 0, 'notes' => $notes, 'description' => insert_lang($description, 2), 'title' => insert_lang($title, 2), 'add_date' => time()), true);
    }
    update_stat('num_seedy_pages', 1);
    $GLOBALS['SITE_DB']->query_insert('seedy_changes', array('the_action' => 'CEDI_ADD_PAGE', 'the_page' => $id, 'date_and_time' => time(), 'ip' => get_ip_address(), 'the_user' => $member));
    require_code('seo2');
    seo_meta_set_for_implicit('seedy_page', strval($id), array($title, $description), $description);
    dispatch_cedi_page_notification($id, 'ADD');
    return $id;
}
Example #26
0
/**
 * Add a chatroom.
 *
 * @param  SHORT_TEXT		The welcome message
 * @param  SHORT_TEXT		The room name
 * @param  MEMBER				The room owner
 * @param  LONG_TEXT			The comma-separated list of users that may access it (blank: no restriction)
 * @param  LONG_TEXT			The comma-separated list of usergroups that may access it (blank: no restriction)
 * @param  LONG_TEXT			The comma-separated list of users that may NOT access it (blank: no restriction)
 * @param  LONG_TEXT			The comma-separated list of usergroups that may NOT access it (blank: no restriction)
 * @param  LANGUAGE_NAME	The room language
 * @param  BINARY				Whether it is an IM room
 * @return AUTO_LINK			The chat room ID
 */
function add_chatroom($welcome, $roomname, $room_owner, $allow2, $allow2_groups, $disallow2, $disallow2_groups, $roomlang, $is_im = 0)
{
    $id = $GLOBALS['SITE_DB']->query_insert('chat_rooms', array('is_im' => $is_im, 'c_welcome' => insert_lang($welcome, 2), 'room_name' => $roomname, 'room_owner' => $room_owner, 'allow_list' => $allow2, 'allow_list_groups' => $allow2_groups, 'disallow_list' => $disallow2, 'disallow_list_groups' => $disallow2_groups, 'room_language' => $roomlang), true);
    log_it('ADD_CHATROOM', strval($id), $roomname);
    decache('side_shoutbox');
    return $id;
}
Example #27
0
/**
 * Add a gallery with the specified parameters.
 *
 * @param  ID_TEXT		The gallery codename
 * @param  SHORT_TEXT	The full human-readeable name of the gallery
 * @param  LONG_TEXT		The description of the gallery
 * @param  SHORT_TEXT	Teaser text for the gallery
 * @param  LONG_TEXT		Hidden notes associated with the gallery
 * @param  ID_TEXT		The parent gallery (blank: no parent)
 * @param  BINARY			Whether images may be put in this gallery
 * @param  BINARY			Whether videos may be put in this gallery
 * @param  BINARY			Whether the gallery serves as a container for automatically created member galleries
 * @param  BINARY			Whether the gallery uses the flow mode interface
 * @param  URLPATH		The representative image of the gallery (blank: none)
 * @param  URLPATH		Watermark (blank: none)
 * @param  URLPATH		Watermark (blank: none)
 * @param  URLPATH		Watermark (blank: none)
 * @param  URLPATH		Watermark (blank: none)
 * @param  BINARY			Whether rating are allowed
 * @param  BINARY			Whether comments are allowed
 * @param  boolean		Whether to skip the check for whether the gallery exists (useful for importers)
 * @param  ?TIME			The add time (NULL: now)
 * @param  ?MEMBER		The gallery owner (NULL: nobody)
 */
function add_gallery($name, $fullname, $description, $teaser, $notes, $parent_id, $accept_images = 1, $accept_videos = 1, $is_member_synched = 0, $flow_mode_interface = 0, $rep_image = '', $watermark_top_left = '', $watermark_top_right = '', $watermark_bottom_left = '', $watermark_bottom_right = '', $allow_rating = 1, $allow_comments = 1, $skip_exists_check = false, $add_date = NULL, $g_owner = NULL)
{
    if (is_null($add_date)) {
        $add_date = time();
    }
    require_code('type_validation');
    if (!is_alphanumeric($name, true)) {
        warn_exit(do_lang_tempcode('BAD_CODENAME'));
    }
    if (!$skip_exists_check) {
        $test = $GLOBALS['SITE_DB']->query_value_null_ok('galleries', 'name', array('name' => $name));
        if (!is_null($test)) {
            warn_exit(do_lang_tempcode('ALREADY_EXISTS', escape_html($name)));
        }
    }
    $GLOBALS['SITE_DB']->query_insert('galleries', array('name' => $name, 'add_date' => $add_date, 'description' => insert_lang_comcode($description, 2), 'teaser' => insert_lang_comcode($teaser, 2), 'notes' => $notes, 'fullname' => insert_lang($fullname, 1), 'watermark_top_left' => $watermark_top_left, 'watermark_top_right' => $watermark_top_right, 'watermark_bottom_left' => $watermark_bottom_left, 'watermark_bottom_right' => $watermark_bottom_right, 'parent_id' => $parent_id, 'accept_images' => $accept_images, 'rep_image' => $rep_image, 'accept_videos' => $accept_videos, 'is_member_synched' => $is_member_synched, 'flow_mode_interface' => $flow_mode_interface, 'allow_rating' => $allow_rating, 'allow_comments' => $allow_comments, 'g_owner' => $g_owner, 'gallery_views' => 0));
    log_it('ADD_GALLERY', $name, $fullname);
    require_code('seo2');
    seo_meta_set_for_implicit('gallery', $name, array($fullname, $description), $description);
    if (function_exists('decache')) {
        decache('main_top_galleries');
        decache('main_recent_galleries');
        decache('main_root_galleries');
        decache('side_root_galleries');
    }
}
Example #28
0
 /**
  * Standard modular install function.
  *
  * @param  ?integer	What version we're upgrading from (NULL: new install)
  * @param  ?integer	What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
  */
 function install($upgrade_from = NULL, $upgrade_from_hack = NULL)
 {
     require_lang('chat');
     if (is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->create_table('chat_rooms', array('id' => '*AUTO', 'room_name' => 'SHORT_TEXT', 'room_owner' => '?INTEGER', 'allow_list' => 'LONG_TEXT', 'allow_list_groups' => 'LONG_TEXT', 'disallow_list' => 'LONG_TEXT', 'disallow_list_groups' => 'LONG_TEXT', 'room_language' => 'LANGUAGE_NAME', 'c_welcome' => 'LONG_TRANS', 'is_im' => 'BINARY'));
         $GLOBALS['SITE_DB']->create_index('chat_rooms', 'room_name', array('room_name'));
         $GLOBALS['SITE_DB']->create_index('chat_rooms', 'is_im', array('is_im', 'room_name'));
         $GLOBALS['SITE_DB']->create_index('chat_rooms', 'first_public', array('is_im', 'id'));
         $GLOBALS['SITE_DB']->create_index('chat_rooms', 'allow_list', array('allow_list(30)'));
         // Create our default chat room. By default, this will be as the shoutbox
         $GLOBALS['SITE_DB']->query_insert('chat_rooms', array('is_im' => 0, 'allow_list_groups' => '', 'disallow_list_groups' => '', 'allow_list' => '', 'disallow_list' => '', 'room_name' => do_lang('DEFAULT_ROOM_GENERAL_CHAT'), 'room_language' => get_site_default_lang(), 'room_owner' => NULL, 'c_welcome' => insert_lang('', 2)));
         $GLOBALS['SITE_DB']->create_table('chat_messages', array('id' => '*AUTO', 'system_message' => 'BINARY', 'ip_address' => 'IP', 'room_id' => 'AUTO_LINK', 'user_id' => 'USER', 'date_and_time' => 'TIME', 'the_message' => 'LONG_TRANS', 'text_colour' => 'SHORT_TEXT', 'font_name' => 'SHORT_TEXT'));
         $GLOBALS['SITE_DB']->create_index('chat_messages', 'ordering', array('date_and_time'));
         $GLOBALS['SITE_DB']->create_index('chat_messages', 'room_id', array('room_id'));
         add_config_option('FLOOD_TIMELIMIT', 'chat_flood_timelimit', 'integer', 'return \'5\';', 'FEATURE', 'SECTION_CHAT');
         $GLOBALS['FORUM_DRIVER']->install_create_custom_field('points_gained_chat', 20, 1, 0, 0, 0, '', 'integer');
         require_lang('chat');
         add_menu_item_simple('main_community', NULL, 'CHAT_LOBBY', '_SEARCH:chat:type=misc');
     }
     if ($upgrade_from < 3 || is_null($upgrade_from)) {
         add_config_option('CHAT_OPTIONS_COLOUR_NAME', 'chat_default_post_colour', 'colour', 'return \'inherit\';', 'FEATURE', 'SECTION_CHAT');
         // NB: compressed up due to 256 character limit
         add_config_option('CHAT_OPTIONS_TEXT_NAME', 'chat_default_post_font', 'list', 'return \'Verdana\';', 'FEATURE', 'SECTION_CHAT', 0, 'Arial|Courier|Georgia|Impact|Times| Trebuchet|Verdana|Tahoma|Geneva|Helvetica');
         add_config_option('PRIVATE_ROOM_DELETION_TIME', 'chat_private_room_deletion_time', 'integer', 'return \'1440\';', 'FEATURE', 'SECTION_CHAT');
     }
     if (!is_null($upgrade_from) && $upgrade_from < 4) {
         $GLOBALS['SITE_DB']->add_table_field('chat_rooms', 'allow_list_groups', 'LONG_TEXT');
         $GLOBALS['SITE_DB']->add_table_field('chat_rooms', 'disallow_list', 'LONG_TEXT');
         $GLOBALS['SITE_DB']->add_table_field('chat_rooms', 'disallow_list_groups', 'LONG_TEXT');
         $GLOBALS['SITE_DB']->add_table_field('chat_rooms', 'c_welcome', 'LONG_TRANS');
         $GLOBALS['SITE_DB']->add_table_field('chat_messages', 'ip_address', 'IP', '127.0.0.1');
         $GLOBALS['SITE_DB']->query_update('chat_rooms', array('allow_list' => ''), array('allow_list' => NULL));
         $GLOBALS['SITE_DB']->alter_table_field('chat_rooms', 'allow_list', 'LONG_TEXT');
     }
     if (is_null($upgrade_from) || $upgrade_from < 5) {
         $usergroups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true);
         foreach (array_keys($usergroups) as $id) {
             $GLOBALS['SITE_DB']->query_insert('group_page_access', array('page_name' => 'cms_chat', 'zone_name' => 'cms', 'group_id' => $id));
             // Don't want to let anyone do chat room moderation just because we let them manage content
         }
     }
     if (is_null($upgrade_from) || $upgrade_from < 6) {
         add_specific_permission('SECTION_CHAT', 'create_private_room', true);
         add_specific_permission('SECTION_CHAT', 'start_im', true);
         add_config_option('USERNAME_CLICK_IM', 'username_click_im', 'tick', 'return \'0\';', 'FEATURE', 'SECTION_CHAT');
         $GLOBALS['SITE_DB']->create_table('chat_blocking', array('member_blocker' => '*USER', 'member_blocked' => '*USER', 'date_and_time' => 'TIME'));
         $GLOBALS['SITE_DB']->create_table('chat_buddies', array('member_likes' => '*USER', 'member_liked' => '*USER', 'date_and_time' => 'TIME'));
         $GLOBALS['SITE_DB']->create_table('chat_events', array('id' => '*AUTO', 'e_type_code' => 'ID_TEXT', 'e_member_id' => 'USER', 'e_room_id' => '?AUTO_LINK', 'e_date_and_time' => 'TIME'));
         $GLOBALS['SITE_DB']->create_index('chat_events', 'event_ordering', array('e_date_and_time'));
     }
     if (!is_null($upgrade_from) && $upgrade_from < 6) {
         $GLOBALS['SITE_DB']->add_table_field('chat_rooms', 'is_im', 'BINARY');
     }
     if (!is_null($upgrade_from) && $upgrade_from < 7) {
         $GLOBALS['SITE_DB']->query_delete('db_meta_indices', array('i_table' => 'chat_active', 'i_name' => 'member_active_select', 'i_fields' => 'member_id'));
         $GLOBALS['SITE_DB']->query('DROP INDEX member_active_select ON ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'chat_active');
     }
     if (is_null($upgrade_from) || $upgrade_from < 8) {
         add_config_option('CHATTING', 'points_chat', 'integer', 'return addon_installed(\'points\')?\'1\':NULL;', 'POINTS', 'COUNT_POINTS_GIVEN');
         add_config_option('COUNT_CHATTERS', 'chat_show_stats_count_users', 'tick', 'return addon_installed(\'stats_block\')?\'0\':NULL;', 'BLOCKS', 'STATISTICS');
         add_config_option('ROOMS', 'chat_show_stats_count_rooms', 'tick', 'return addon_installed(\'stats_block\')?\'0\':NULL;', 'BLOCKS', 'STATISTICS');
         add_config_option('COUNT_CHATPOSTS', 'chat_show_stats_count_messages', 'tick', 'return addon_installed(\'stats_block\')?\'0\':NULL;', 'BLOCKS', 'STATISTICS');
     }
     if (!is_null($upgrade_from) && $upgrade_from < 9) {
         $GLOBALS['SITE_DB']->promote_text_field_to_comcode('chat_messages', 'the_message', 'id', 4, true);
         $GLOBALS['SITE_DB']->query_delete('chat_messages');
         delete_config_option('is_on_chat');
         $GLOBALS['SITE_DB']->add_table_field('chat_messages', 'system_message', 'BINARY');
     }
     if (is_null($upgrade_from) || $upgrade_from < 10) {
         $GLOBALS['SITE_DB']->drop_if_exists('chat_active');
         $GLOBALS['SITE_DB']->create_table('chat_active', array('id' => '*AUTO', 'member_id' => 'USER', 'room_id' => '?AUTO_LINK', 'date_and_time' => 'TIME'));
         $GLOBALS['SITE_DB']->create_index('chat_active', 'active_ordering', array('date_and_time'));
         $GLOBALS['SITE_DB']->create_index('chat_active', 'member_select', array('member_id'));
         $GLOBALS['SITE_DB']->create_index('chat_active', 'room_select', array('room_id'));
         $GLOBALS['SITE_DB']->create_table('chat_sound_effects', array('s_member' => '*USER', 's_effect_id' => '*ID_TEXT', 's_url' => 'URLPATH'));
         $rooms = $GLOBALS['SITE_DB']->query_select('chat_rooms', array('id'));
         foreach ($rooms as $room) {
             // Set access
             $admin_groups = $GLOBALS['FORUM_DRIVER']->get_super_admin_groups();
             $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true);
             foreach (array_keys($groups) as $group_id) {
                 if (in_array($group_id, $admin_groups)) {
                     continue;
                 }
                 $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'chat', 'category_name' => strval($room['id']), 'group_id' => $group_id));
             }
         }
         add_specific_permission('SECTION_CHAT', 'moderate_my_private_rooms', true);
         add_specific_permission('SECTION_CHAT', 'ban_chatters_from_rooms', false);
         // NB: edit_lowrange_content may be overridden for the chat module also, allowing editing messages in rooms
         add_config_option('SITEWIDE_IM', 'sitewide_im', 'tick', 'return \'0\';', 'FEATURE', 'SECTION_CHAT');
     }
     if (is_null($upgrade_from) || $upgrade_from < 11) {
         add_config_option('GROUP_PRIVATE_CHATROOMS', 'group_private_chatrooms', 'tick', 'return is_null($old=get_value(\'no_group_private_chatrooms\'))?\'1\':invert_value($old);', 'FEATURE', 'SECTION_CHAT');
     }
 }
Example #29
0
/**
 * Fifth installation step: more core tables.
 *
 * @return tempcode		Progress report / UI
 */
function step_5_core_2()
{
    global $LANG;
    $GLOBALS['SITE_DB']->drop_if_exists('zones');
    $GLOBALS['SITE_DB']->create_table('zones', array('zone_name' => '*ID_TEXT', 'zone_title' => 'SHORT_TRANS', 'zone_default_page' => 'ID_TEXT', 'zone_header_text' => 'SHORT_TRANS', 'zone_theme' => 'ID_TEXT', 'zone_wide' => '?BINARY', 'zone_require_session' => 'BINARY', 'zone_displayed_in_menu' => 'BINARY'));
    require_lang('zones');
    $trans1 = insert_lang(do_lang('A_SITE_ABOUT', '???'), 1, NULL, false, NULL, $LANG);
    $trans2 = insert_lang(do_lang('HEADER_TEXT_ADMINZONE'), 1, NULL, false, NULL, $LANG);
    if (file_exists(get_file_base() . '/collaboration')) {
        $trans3 = insert_lang(do_lang('HEADER_TEXT_collaboration'), 1, NULL, false, NULL, $LANG);
    }
    $trans4 = insert_lang(do_lang('A_SITE_ABOUT', '???'), 1, NULL, false, NULL, $LANG);
    $trans6 = insert_lang(do_lang('CMS'), 1, NULL, false, NULL, $LANG);
    $trans8 = insert_lang(do_lang('GUIDES'), 1, NULL, false, NULL, $LANG);
    $GLOBALS['SITE_DB']->query_insert('zones', array('zone_displayed_in_menu' => 0, 'zone_name' => '', 'zone_title' => insert_lang(do_lang('_WELCOME'), 1), 'zone_default_page' => 'start', 'zone_header_text' => $trans1, 'zone_theme' => '-1', 'zone_wide' => 0, 'zone_require_session' => 0));
    $GLOBALS['SITE_DB']->query_insert('zones', array('zone_displayed_in_menu' => 1, 'zone_name' => 'adminzone', 'zone_title' => insert_lang(do_lang('ADMIN_ZONE'), 1), 'zone_default_page' => 'start', 'zone_header_text' => $trans2, 'zone_theme' => 'default', 'zone_wide' => 0, 'zone_require_session' => 1));
    $GLOBALS['SITE_DB']->query_insert('zones', array('zone_displayed_in_menu' => 1, 'zone_name' => 'site', 'zone_title' => insert_lang(do_lang('SITE'), 1), 'zone_default_page' => 'start', 'zone_header_text' => $trans4, 'zone_theme' => '-1', 'zone_wide' => 0, 'zone_require_session' => 0));
    if (file_exists(get_file_base() . '/collaboration')) {
        $GLOBALS['SITE_DB']->query_insert('zones', array('zone_displayed_in_menu' => 1, 'zone_name' => 'collaboration', 'zone_title' => insert_lang(do_lang('COLLABORATION'), 1), 'zone_default_page' => 'start', 'zone_header_text' => $trans3, 'zone_theme' => '-1', 'zone_wide' => 0, 'zone_require_session' => 0));
    }
    //$GLOBALS['SITE_DB']->query_insert('zones',array('zone_displayed_in_menu'=>0,'zone_name'=>'docs','zone_title'=>insert_lang(do_lang('GUIDES'),1),'zone_default_page'=>'userguide','zone_header_text'=>$trans8,'zone_theme'=>'-1','zone_wide'=>0,'zone_require_session'=>0));
    $GLOBALS['SITE_DB']->query_insert('zones', array('zone_displayed_in_menu' => 1, 'zone_name' => 'cms', 'zone_title' => insert_lang(do_lang('CMS'), 1), 'zone_default_page' => 'cms', 'zone_header_text' => $trans6, 'zone_theme' => 'default', 'zone_wide' => 0, 'zone_require_session' => 1));
    // Forums
    $forum_type = post_param('forum_type');
    if ($forum_type == 'ocf') {
        $trans5 = insert_lang(do_lang('FORUM'), 1, NULL, false, NULL, $LANG);
        $GLOBALS['SITE_DB']->query_insert('zones', array('zone_displayed_in_menu' => 1, 'zone_name' => 'forum', 'zone_title' => insert_lang(do_lang('SECTION_FORUMS'), 1), 'zone_default_page' => 'forumview', 'zone_header_text' => $trans5, 'zone_theme' => '-1', 'zone_wide' => NULL, 'zone_require_session' => 0));
    }
    $GLOBALS['SITE_DB']->drop_if_exists('modules');
    $GLOBALS['SITE_DB']->create_table('modules', array('module_the_name' => '*ID_TEXT', 'module_author' => 'ID_TEXT', 'module_organisation' => 'ID_TEXT', 'module_hacked_by' => 'ID_TEXT', 'module_hack_version' => '?INTEGER', 'module_version' => 'INTEGER'));
    $GLOBALS['SITE_DB']->drop_if_exists('blocks');
    $GLOBALS['SITE_DB']->create_table('blocks', array('block_name' => '*ID_TEXT', 'block_author' => 'ID_TEXT', 'block_organisation' => 'ID_TEXT', 'block_hacked_by' => 'ID_TEXT', 'block_hack_version' => '?INTEGER', 'block_version' => 'INTEGER'));
    $GLOBALS['SITE_DB']->drop_if_exists('sessions');
    $GLOBALS['SITE_DB']->create_table('sessions', array('the_session' => '*INTEGER', 'last_activity' => 'TIME', 'the_user' => 'USER', 'ip' => 'IP', 'session_confirmed' => 'BINARY', 'session_invisible' => 'BINARY', 'cache_username' => 'SHORT_TEXT', 'the_zone' => 'ID_TEXT', 'the_page' => 'ID_TEXT', 'the_type' => 'ID_TEXT', 'the_id' => 'ID_TEXT', 'the_title' => 'SHORT_TEXT'));
    $GLOBALS['SITE_DB']->create_index('sessions', 'delete_old', array('last_activity'));
    $GLOBALS['SITE_DB']->create_index('sessions', 'the_user', array('the_user'));
    $GLOBALS['SITE_DB']->create_index('sessions', 'userat', array('the_zone', 'the_page', 'the_type', 'the_id'));
    $GLOBALS['SITE_DB']->drop_if_exists('https_pages');
    $GLOBALS['SITE_DB']->create_table('https_pages', array('https_page_name' => '*ID_TEXT'));
    // What usergroups may view this category
    $GLOBALS['SITE_DB']->drop_if_exists('group_category_access');
    $GLOBALS['SITE_DB']->create_table('group_category_access', array('module_the_name' => '*ID_TEXT', 'category_name' => '*ID_TEXT', 'group_id' => '*GROUP'));
    $GLOBALS['SITE_DB']->drop_if_exists('seo_meta');
    $GLOBALS['SITE_DB']->create_table('seo_meta', array('id' => '*AUTO', 'meta_for_type' => 'ID_TEXT', 'meta_for_id' => 'ID_TEXT', 'meta_keywords' => 'LONG_TRANS', 'meta_description' => 'LONG_TRANS'));
    $GLOBALS['SITE_DB']->create_index('seo_meta', 'alt_key', array('meta_for_type', 'meta_for_id'));
    $GLOBALS['SITE_DB']->create_index('seo_meta', 'ftjoin_dmeta_keywords', array('meta_keywords'));
    $GLOBALS['SITE_DB']->create_index('seo_meta', 'ftjoin_dmeta_description', array('meta_description'));
    return do_template('INSTALLER_DONE_SOMETHING', array('_GUID' => '685ebf53cf9fc3f728168fed2f01a5a1', 'SOMETHING' => do_lang_tempcode('SECONDARY_CORE_INSTALLED')));
}
Example #30
0
/**
 * Standard code module initialisation function.
 */
function init__site()
{
    if (defined('BREADCRUMB_CROP_LENGTH')) {
        return;
    }
    global $HELPER_PANEL_TEXT, $HELPER_PANEL_HTML, $HELPER_PANEL_PIC, $HELPER_PANEL_TUTORIAL;
    $HELPER_PANEL_TEXT = '';
    $HELPER_PANEL_HTML = '';
    $HELPER_PANEL_PIC = '';
    $HELPER_PANEL_TUTORIAL = '';
    global $REQUEST_PAGE_NEST_LEVEL;
    $REQUEST_PAGE_NEST_LEVEL = 0;
    global $REDIRECT_CACHE;
    $REDIRECT_CACHE = array();
    global $REDIRECTED_TO;
    $REDIRECTED_TO = NULL;
    global $REFRESH_URL, $FORCE_META_REFRESH, $EXTRA_HEAD, $EXTRA_FOOT, $QUICK_REDIRECT;
    $REFRESH_URL[0] = '';
    $REFRESH_URL[1] = 0;
    $FORCE_META_REFRESH = false;
    if (!isset($EXTRA_HEAD)) {
        $EXTRA_HEAD = new ocp_tempcode();
    }
    if (!isset($EXTRA_FOOT)) {
        $EXTRA_FOOT = new ocp_tempcode();
    }
    $QUICK_REDIRECT = false;
    global $FEED_URL, $FEED_URL_2;
    $FEED_URL = NULL;
    $FEED_URL_2 = NULL;
    global $NON_CANONICAL_PARAMS;
    // We only bother listing ones the software itself may inject - otherwise admin responsible for their own curation of canonical settings
    $NON_CANONICAL_PARAMS = array('wide_high', 'wide', 'wide_print', 'root', 'filtered', 'utheme', 'active_filter', 'redirected', 'redirect_url', 'redirect', 'redirect_passon');
    $canonical_keep_params = explode(',', is_null(get_value('canonical_keep_params')) ? '' : get_value('canonical_keep_params'));
    foreach (array_keys($_GET) as $key) {
        if (substr($key, 0, 5) == 'keep_' && !@in_array($key, $canonical_keep_params)) {
            $NON_CANONICAL_PARAMS[] = $key;
        }
    }
    global $ATTACHED_MESSAGES, $ATTACHED_MESSAGES_RAW, $FAILED_TO_ATTACH_ALL_ERRORS;
    $ATTACHED_MESSAGES = new ocp_tempcode();
    $ATTACHED_MESSAGES_RAW = array();
    $FAILED_TO_ATTACH_ALL_ERRORS = false;
    global $DONE_HEADER;
    $DONE_HEADER = false;
    // We may fill these in from the code, or we may not
    global $SEO_KEYWORDS, $SEO_DESCRIPTION, $SEO_TITLE;
    $SEO_KEYWORDS = NULL;
    $SEO_DESCRIPTION = NULL;
    $SEO_TITLE = NULL;
    global $PAGE_STRING, $LAST_COMCODE_PARSED_TITLE;
    $PAGE_STRING = NULL;
    $LAST_COMCODE_PARSED_TITLE = '';
    global $BREADCRUMBS, $BREADCRUMB_SET_PARENTS, $BREADCRUMB_EXTRA_SEGMENTS, $DISPLAYED_TITLE, $BREADCRUMB_SET_SELF;
    $BREADCRUMBS = NULL;
    $BREADCRUMB_SET_PARENTS = array();
    $BREADCRUMB_EXTRA_SEGMENTS = new ocp_tempcode();
    $DISPLAYED_TITLE = NULL;
    $BREADCRUMB_SET_SELF = NULL;
    $bcl = get_value('breadcrumb_crop_length');
    define('BREADCRUMB_CROP_LENGTH', is_null($bcl) ? 26 : intval($bcl));
    global $PT_PAIR_CACHE_CP;
    $PT_PAIR_CACHE_CP = array();
    global $ATTACH_MESSAGE_CALLED;
    $ATTACH_MESSAGE_CALLED = 0;
    global $ZONE, $RELATIVE_PATH;
    $zone = get_zone_name();
    $real_zone = $RELATIVE_PATH == '_tests' || $RELATIVE_PATH == 'data' || $RELATIVE_PATH == 'data_custom' ? get_param('zone', '') : $zone;
    $ZONE = persistant_cache_get(array('ZONE', $real_zone));
    if ($ZONE === NULL) {
        $zones = $GLOBALS['SITE_DB']->query_select('zones', array('*'), array('zone_name' => $real_zone), '', 1);
        if (!array_key_exists(0, $zones) && is_dir(get_file_base() . '/' . $real_zone . '/' . 'pages')) {
            $GLOBALS['SITE_DB']->query_insert('zones', array('zone_name' => $real_zone, 'zone_title' => insert_lang($real_zone, 1), 'zone_default_page' => 'start', 'zone_header_text' => insert_lang($real_zone, 1), 'zone_theme' => 'default', 'zone_wide' => 0, 'zone_require_session' => 0, 'zone_displayed_in_menu' => 0));
            require_code('menus2');
            add_menu_item_simple('zone_menu', NULL, $real_zone, $real_zone . ':', 0, 1);
            $zones = $GLOBALS['SITE_DB']->query_select('zones z LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND z.zone_header_text=t.id', array('z.*', 'text_original AS zone_header_text_trans'), array('zone_name' => $real_zone), '', 1);
        }
        if (array_key_exists(0, $zones)) {
            $ZONE = $zones[0];
            $ZONE['zone_header_text_trans'] = get_translated_text($ZONE['zone_header_text']);
            persistant_cache_set(array('ZONE', $real_zone), $ZONE);
        }
        if ($ZONE === NULL) {
            $zones = $GLOBALS['SITE_DB']->query_select('zones', array('*'), array('zone_name' => ''), '', 1);
            $ZONE = $zones[0];
            $ZONE['zone_header_text_trans'] = get_translated_text($ZONE['zone_header_text']);
            warn_exit(do_lang_tempcode('BAD_ZONE', escape_html($real_zone)));
        }
        unset($zones);
    }
    if ($ZONE !== NULL && $ZONE['zone_wide'] === NULL) {
        $ZONE['zone_wide'] = get_forum_type() == 'ocf' ? $GLOBALS['FORUM_DRIVER']->get_member_row_field(get_member(), 'm_zone_wide') : 1;
    }
    if ($ZONE['zone_name'] == 'adminzone' || $ZONE['zone_name'] == 'cms') {
        require_css('adminzone');
    }
    $_zone = get_zone_name();
    $REDIRECT_CACHE = array($_zone => array());
    if (addon_installed('redirects_editor')) {
        $redirect = persistant_cache_get(array('REDIRECT', $_zone));
        if ($redirect === NULL) {
            $redirect = $GLOBALS['SITE_DB']->query_select('redirects', array('*'));
            persistant_cache_set(array('REDIRECT', $_zone), $redirect);
        }
        foreach ($redirect as $r) {
            if ($r['r_from_zone'] == $r['r_to_zone'] && $r['r_from_page'] == $r['r_to_page']) {
                continue;
            }
            $REDIRECT_CACHE[$r['r_from_zone']][$r['r_from_page']] = $r;
        }
    }
    // SEO redirection
    require_code('urls');
    if (can_try_mod_rewrite()) {
        $ruri = ocp_srv('REQUEST_URI');
        $old_style = get_option('htm_short_urls') != '1';
        if (!headers_sent() && running_script('index') && isset($_SERVER['HTTP_HOST']) && count($_POST) == 0 && (strpos($ruri, '/pg/') === false || !$old_style) && (strpos($ruri, '.htm') === false || $old_style)) {
            $GLOBALS['HTTP_STATUS_CODE'] = '301';
            header('HTTP/1.0 301 Moved Permanently');
            header('Location: ' . get_self_url(true));
            exit;
        }
    }
    // Search engine having session in URL, we don't like this
    if (get_bot_type() !== NULL && isset($_SERVER['HTTP_HOST']) && count($_POST) == 0 && get_param_integer('keep_session', NULL) !== NULL) {
        $GLOBALS['HTTP_STATUS_CODE'] = '301';
        header('HTTP/1.0 301 Moved Permanently');
        header('Location: ' . get_self_url(true, false, array('keep_session' => NULL, 'keep_print' => NULL)));
        exit;
    }
    // Detect bad access domain
    global $SITE_INFO;
    $access_host = preg_replace('#:.*#', '', ocp_srv('HTTP_HOST'));
    if ($access_host != '' && isset($_SERVER['HTTP_HOST'])) {
        $parsed_base_url = parse_url(get_base_url());
        if (array_key_exists('host', $parsed_base_url) && strtolower($parsed_base_url['host']) != strtolower($access_host)) {
            if (!array_key_exists('ZONE_MAPPING_' . get_zone_name(), $SITE_INFO)) {
                if ($GLOBALS['FORUM_DRIVER']->is_super_admin(get_member())) {
                    attach_message(do_lang_tempcode('BAD_ACCESS_DOMAIN', escape_html($parsed_base_url['host']), escape_html($access_host)), 'warn');
                }
                header('Location: ' . str_replace(chr(13), '', str_replace(chr(10), '', str_replace($access_host, $parsed_base_url['host'], get_self_url_easy()))));
                exit;
            }
        }
    }
    // The most important security check
    global $SESSION_CONFIRMED;
    get_member();
    // Make sure we've loaded our backdoor if installed
    require_code('permissions');
    if ($ZONE['zone_require_session'] == 1) {
        header('X-Frame-Options: SAMEORIGIN');
    }
    // Clickjacking protection
    if ($ZONE['zone_name'] != '' && !is_httpauth_login() && (get_session_id() == -1 || $SESSION_CONFIRMED == 0) && $ZONE['zone_require_session'] == 1 && get_page_name() != 'login') {
        access_denied($real_zone == 'data' || has_zone_access(get_member(), $ZONE['zone_name']) ? 'ZONE_ACCESS_SESSION' : 'ZONE_ACCESS', $ZONE['zone_name'], true);
    } else {
        if ($real_zone == 'data' || has_zone_access(get_member(), $ZONE['zone_name'])) {
            global $NON_PAGE_SCRIPT;
            if ($NON_PAGE_SCRIPT == 0 && !has_page_access(get_member(), get_page_name(), $ZONE['zone_name'], true)) {
                access_denied('PAGE_ACCESS');
            }
        } else {
            /*		if ($ZONE['zone_name']=='adminzone')	 GoogleAds will pick up on ANY URL any go and CRAWL IT. So don't use with googleads unless you want googlead-triggering-heart-attacks ;)
            				log_hack_attack_and_exit('ADMINZONE_ACCESS_DENIED');*/
            if (get_page_name() != 'login') {
                access_denied('ZONE_ACCESS', $ZONE['zone_name'], true);
            }
        }
    }
}