/**
  * Standard modular run function for snippet hooks. Generates XHTML to insert into a page using AJAX.
  *
  * @return tempcode  The snippet
  */
 function run()
 {
     $type = get_param('type');
     if (!has_zone_access(get_member(), 'adminzone')) {
         return new ocp_tempcode();
     }
     decache('main_staff_checklist');
     require_lang('staff_checklist');
     switch ($type) {
         case 'add':
             $recurinterval = get_param_integer('recurinterval', 0);
             $task_title = get_param('tasktitle', false, true);
             $id = $GLOBALS['SITE_DB']->query_insert('customtasks', array('tasktitle' => $task_title, 'datetimeadded' => time(), 'recurinterval' => $recurinterval, 'recurevery' => get_param('recurevery'), 'taskisdone' => NULL), true);
             require_code('notifications');
             $subject = do_lang('CT_NOTIFICATION_MAIL_SUBJECT', get_site_name(), $task_title);
             $mail = do_lang('CT_NOTIFICATION_MAIL', comcode_escape(get_site_name()), comcode_escape($task_title));
             dispatch_notification('checklist_task', NULL, $subject, $mail);
             return do_template('BLOCK_MAIN_STAFF_CHECKLIST_CUSTOM_TASK', array('TASKTITLE' => comcode_to_tempcode(get_param('tasktitle', false, true)), 'DATETIMEADDED' => display_time_period(time()), 'RECURINTERVAL' => $recurinterval == 0 ? '' : integer_format($recurinterval), 'RECUREVERY' => get_param('recurevery'), 'TASKDONE' => 'not_completed', 'ID' => strval($id)));
         case 'delete':
             $GLOBALS['SITE_DB']->query_delete('customtasks', array('id' => get_param_integer('id')), '', 1);
             break;
         case 'mark_done':
             $GLOBALS['SITE_DB']->query_update('customtasks', array('taskisdone' => time()), array('id' => get_param_integer('id')), '', 1);
             break;
         case 'mark_undone':
             $GLOBALS['SITE_DB']->query_update('customtasks', array('taskisdone' => NULL), array('id' => get_param_integer('id')), '', 1);
             break;
     }
     return new ocp_tempcode();
 }
Example #2
0
/**
 * Add a forum poll.
 *
 * @param  AUTO_LINK		The ID of the topic to add the poll to.
 * @param  SHORT_TEXT	The question.
 * @param  BINARY			Whether the result tallies are kept private until the poll is made non-private.
 * @param  BINARY			Whether the poll is open for voting.
 * @param  integer		The minimum number of selections that may be made.
 * @param  integer		The maximum number of selections that may be made.
 * @param  BINARY			Whether members must have a post in the topic before they made vote.
 * @param  array			A list of pairs of the potential voteable answers and the number of votes.
 * @param  boolean		Whether to check there are permissions to make the poll.
 * @return AUTO_LINK 	The ID of the newly created forum poll.
 */
function ocf_make_poll($topic_id, $question, $is_private, $is_open, $minimum_selections, $maximum_selections, $requires_reply, $answers, $check_permissions = true)
{
    require_code('ocf_polls');
    if ($check_permissions && !ocf_may_attach_poll($topic_id)) {
        access_denied('I_ERROR');
    }
    $poll_id = $GLOBALS['FORUM_DB']->query_insert('f_polls', array('po_question' => $question, 'po_cache_total_votes' => 0, 'po_is_private' => $is_private, 'po_is_open' => $is_open, 'po_minimum_selections' => $minimum_selections, 'po_maximum_selections' => $maximum_selections, 'po_requires_reply' => $requires_reply), true);
    foreach ($answers as $answer) {
        if (is_array($answer)) {
            list($answer, $num_votes) = $answer;
        } else {
            $num_votes = 0;
        }
        $GLOBALS['FORUM_DB']->query_insert('f_poll_answers', array('pa_poll_id' => $poll_id, 'pa_answer' => $answer, 'pa_cache_num_votes' => $num_votes));
    }
    $map = array('t_poll_id' => $poll_id);
    // Now make the topic validated if this is attaching immediately
    if (get_param_integer('re_validate', 0) == 1) {
        $forum_id = $GLOBALS['FORUM_DB']->query_value('f_topics', 't_forum_id', array('id' => $topic_id));
        if (is_null($forum_id) || has_specific_permission(get_member(), 'bypass_validation_midrange_content', 'topics', array('forums', $forum_id))) {
            $map['t_validated'] = 1;
        }
    }
    $GLOBALS['FORUM_DB']->query_update('f_topics', $map, array('id' => $topic_id), '', 1);
    return $poll_id;
}
Example #3
0
/**
 * Function to quickly (efficiently) check to see if there's been any chat activity.
 */
function chat_poller()
{
    $message_id = get_param_integer('message_id', -1);
    $event_id = get_param_integer('event_id', -1);
    if (file_exists(get_custom_file_base() . '/data_custom/modules/chat/chat_last_full_check.dat') && filemtime(get_custom_file_base() . '/data_custom/modules/chat/chat_last_full_check.dat') > time() - 3 && ($message_id != -1 && file_exists(get_custom_file_base() . '/data_custom/modules/chat/chat_last_msg.dat') && intval(file_get_contents(get_custom_file_base() . '/data_custom/modules/chat/chat_last_msg.dat', FILE_TEXT)) <= $message_id) && ($event_id != -1 && file_exists(get_custom_file_base() . '/data_custom/modules/chat/chat_last_event.dat') && intval(file_get_contents(get_custom_file_base() . '/data_custom/modules/chat/chat_last_event.dat', FILE_TEXT)) <= $event_id)) {
        load_user_stuff();
        require_code('zones');
        // Zone is needed because zones are where all ocPortal pages reside
        require_code('config');
        // Config is needed for much active stuff
        require_code('users');
        // Users are important due to permissions
        $room_id = get_param_integer('room_id', -1);
        require_code('chat');
        chat_room_prune($room_id);
        header("Cache-Control: no-cache, must-revalidate");
        // HTTP/1.1
        header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
        // Date in the past
        header('Content-Type: application/xml');
        $output = '<?xml version="1.0" encoding="' . get_charset() . '" ?' . '>
			<response>
				<result>
					<chat_null>' . strval($room_id) . '</chat_null>
				</result>
			</response>';
        exit($output);
    }
    touch(get_custom_file_base() . '/data_custom/modules/chat/chat_last_full_check.dat');
}
Example #4
0
/**
 * Log permission checks to the permission_checks.log file
 *
 * @param  MEMBER         The user checking against
 * @param  ID_TEXT        The function that was called to check a permission
 * @param  array          Parameters to this permission-checking function
 * @param  boolean        Whether the permission was held
 */
function _handle_permission_check_logging($member, $op, $params, $result)
{
    global $PERMISSION_CHECK_LOGGER;
    if ($op == 'has_specific_permission') {
        require_all_lang();
        $params[0] = $params[0] . ' ("' . do_lang('PT_' . $params[0]) . '")';
    }
    $str = $op;
    if (count($params) != 0) {
        $str .= ': ';
        foreach ($params as $i => $p) {
            if ($i != 0) {
                $str .= ',';
            }
            $str .= is_string($p) ? $p : (is_null($p) ? '' : strval($p));
        }
    }
    if ($PERMISSION_CHECK_LOGGER !== false && !$result) {
        fwrite($PERMISSION_CHECK_LOGGER, "\t" . $str);
        $username = $GLOBALS['FORUM_DRIVER']->get_username($member);
        if (is_null($username)) {
            $username = do_lang('UNKNOWN');
        }
        if ($member != get_member()) {
            fwrite($PERMISSION_CHECK_LOGGER, ' -- ' . $username);
        }
        //	fwrite($PERMISSION_CHECK_LOGGER,' --> '.($result?do_lang('YES'):do_lang('NO')).chr(10));
        fwrite($PERMISSION_CHECK_LOGGER, chr(10));
        sync_file(get_custom_file_base() . '/data_custom/permissioncheckslog.php');
    }
    if (function_exists('fb') && get_param_integer('keep_firephp', 0) == 1 && !headers_sent()) {
        fb('Permission check ' . ($result ? 'PASSED' : 'FAILED') . ': ' . $str);
    }
}
Example #5
0
/**
 * Pop-up some rules.
 */
function rules_script()
{
    $id = get_param_integer('id', NULL);
    if (is_null($id)) {
        require_code('site');
        $output = request_page('rules', true);
        $title = do_lang_tempcode('RULES');
    } else {
        if (!has_category_access(get_member(), 'forums', strval($id))) {
            warn_exit(do_lang_tempcode('ACCESS_DENIED'));
        }
        $forum_rows = $GLOBALS['FORUM_DB']->query_select('f_forums', array('*'), array('id' => $id), '', 1);
        if (!array_key_exists(0, $forum_rows)) {
            warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
        }
        $forum_row = $forum_rows[0];
        require_lang('ocf');
        $question = get_translated_tempcode($forum_row['f_intro_question'], $GLOBALS['FORUM_DB']);
        $answer = $forum_row['f_intro_answer'];
        $output = do_template('OCF_FORUM_INTRO_QUESTION_POPUP', array('_GUID' => '6f2dc12b616219ff982654b73ef979b2', 'QUESTION' => $question, 'ANSWER' => $answer));
        $title = $answer == '' ? do_lang_tempcode('FORUM_RULES') : do_lang_tempcode('INTRO_QUESTION');
    }
    $tpl = do_template('POPUP_HTML_WRAP', array('_GUID' => '26c4dbc7a4737310f089583f1048cb13', 'TITLE' => $title, 'TARGET' => '_top', 'CONTENT' => $output));
    $tpl->evaluate_echo();
}
Example #6
0
/**
 * Standard code module initialisation function.
 */
function init__database__xml()
{
    global $SCHEMA_CACHE, $DIR_CONTENTS_CACHE;
    $SCHEMA_CACHE = array();
    $DIR_CONTENTS_CACHE = array();
    global $DELIMITERS_FLIPPED, $DELIMITERS, $SYMBOL_DELIMINITER, $DELIMITERS_ALPHA;
    $DELIMITERS = array_merge(array("\t", ' ', "\n"), _get_sql_keywords());
    sort($DELIMITERS);
    $DELIMITERS_FLIPPED = array_flip($DELIMITERS);
    $SYMBOL_DELIMINITER = array_flip(array("\t", ' ', "\n", '+', '-', '*', '/', '>', '<', '=', "'", '"', "\\'", '(', ')', ','));
    foreach ($DELIMITERS as $d) {
        if (!isset($DELIMITERS_ALPHA[$d[0]])) {
            $DELIMITERS_ALPHA[$d[0]] = array();
        }
        $DELIMITERS_ALPHA[$d[0]][] = $d;
    }
    global $TABLE_BASES;
    $TABLE_BASES = array();
    // Support for chaining a DB- to make reads faster
    global $SITE_INFO;
    if (array_key_exists('db_chain_type', $SITE_INFO) && !running_script('xml_db_import') && get_param_integer('keep_no_chain', 0) != 1) {
        require_code('database/' . $SITE_INFO['db_chain_type']);
        $GLOBALS['XML_CHAIN_DB'] = new database_driver($SITE_INFO['db_chain'], $SITE_INFO['db_chain_host'], $SITE_INFO['db_chain_user'], $SITE_INFO['db_chain_password'], get_table_prefix(), false, object_factory('Database_Static_' . $SITE_INFO['db_chain_type']));
    } else {
        $GLOBALS['XML_CHAIN_DB'] = NULL;
    }
    if (function_exists('set_time_limit')) {
        @set_time_limit(100);
    }
    // XML DB is *slow*
}
Example #7
0
 function auth_set($member_id, $oauth_url)
 {
     require_lang('twitter');
     require_code('twitter');
     $api_key = get_option('twitter_api_key', true);
     $api_secret = get_option('twitter_api_secret', true);
     $twitter = new Twitter($api_key, $api_secret);
     if (get_param_integer('oauth_in_progress', 0) == 0) {
         $response = $twitter->oAuthRequestToken($oauth_url->evaluate());
         $twitter->oAuthAuthorize($response['oauth_token']);
         exit;
     }
     $response = $twitter->oAuthAccessToken(get_param('oauth_token'), get_param('oauth_verifier'));
     if (!isset($response['oauth_token'])) {
         attach_message(do_lang_tempcode('TWITTER_OAUTH_FAIL', escape_html($response['message'])), 'warn');
         return false;
     }
     $save_to = 'twitter_oauth_token';
     if (!is_null($member_id)) {
         $save_to .= '__' . strval($member_id);
     }
     set_long_value($save_to, $response['oauth_token']);
     $save_to = 'twitter_oauth_token_secret';
     if (!is_null($member_id)) {
         $save_to .= '__' . strval($member_id);
     }
     set_long_value($save_to, $response['oauth_token_secret']);
     return true;
 }
Example #8
0
 /**
  * Standard modular run function for snippet hooks. Generates XHTML to insert into a page using AJAX.
  *
  * @return tempcode  The snippet
  */
 function run()
 {
     $sup = get_param('block_map_sup', '', true);
     $_map = get_param('block_map', false, true);
     if ($sup != '') {
         $_map .= ',' . $sup;
     }
     require_code('blocks');
     $map = block_params_str_to_arr($_map);
     if (!array_key_exists('block', $map)) {
         return new ocp_tempcode();
     }
     $auth_key = get_param_integer('auth_key');
     // Check permissions
     $test = $GLOBALS['SITE_DB']->query_value_null_ok('temp_block_permissions', 'p_block_constraints', array('p_session_id' => get_session_id(), 'id' => $auth_key));
     if (is_null($test) || !block_signature_check(block_params_str_to_arr($test), $map)) {
         require_lang('permissions');
         return paragraph(do_lang_tempcode('ACCESS_DENIED__ACCESS_DENIED', escape_html($map['block'])));
     }
     // Cleanup
     $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'temp_block_permissions WHERE p_time<' . strval(time() - 60 * 60 * intval(get_option('session_expiry_time'))));
     // Return block snippet
     global $CSSS, $JAVASCRIPTS;
     $CSSS = array();
     $JAVASCRIPTS = array();
     $out = new ocp_tempcode();
     $out->attach(symbol_tempcode('CSS_TEMPCODE'));
     $out->attach(symbol_tempcode('JS_TEMPCODE'));
     $out->attach(do_block($map['block'], $map));
     return $out;
 }
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     require_code('downloads');
     require_css('downloads');
     require_lang('downloads');
     $zone = array_key_exists('zone', $map) ? $map['zone'] : get_module_zone('downloads');
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'max';
     $max = get_param_integer('max', 10);
     if ($max < 1) {
         $max = 1;
     }
     $start = get_param_integer('start', 0);
     $rows = $GLOBALS['SITE_DB']->query_select('download_downloads', array('*'), array('validated' => 1), 'ORDER BY num_downloads DESC', $max, $start);
     $content = new ocp_tempcode();
     foreach ($rows as $i => $row) {
         if ($i != 0) {
             $content->attach(do_template('BLOCK_SEPARATOR'));
         }
         $content->attach(get_download_html($row, true, true, $zone));
     }
     $page_num = intval(floor(floatval($start) / floatval($max))) + 1;
     $count = $GLOBALS['SITE_DB']->query_value('download_downloads', 'COUNT(*)', array('validated' => 1));
     $num_pages = intval(ceil(floatval($count) / floatval($max)));
     if ($num_pages == 0) {
         $page_num = 0;
     }
     $previous_url = $start == 0 ? new ocp_tempcode() : build_url(array('page' => '_SELF', 'start' => $start - $max), '_SELF');
     $next_url = $page_num == $num_pages ? new ocp_tempcode() : build_url(array('page' => '_SELF', 'start' => $start + $max), '_SELF');
     $browse = do_template('NEXT_BROWSER_BROWSE_NEXT', array('_GUID' => '15ca70ec400629f67edefa869fb1f1a8', 'NEXT_LINK' => $next_url, 'PREVIOUS_LINK' => $previous_url, 'PAGE_NUM' => integer_format($page_num), 'NUM_PAGES' => integer_format($num_pages)));
     return do_template('BLOCK_MAIN_DOWNLOAD_TEASE', array('_GUID' => 'a164e33c0b4ace4bae945c39f2f00ca9', 'CONTENT' => $content, 'BROWSE' => $browse));
 }
Example #10
0
/**
 * Check a post would be valid.
 *
 * @param  LONG_TEXT		The post.
 * @param  ?AUTO_LINK	The ID of the topic the post would be in (NULL: don't check with regard to any particular topic).
 * @param  ?MEMBER		The poster (NULL: current member).
 * @return ?array			Row of the existing post if a double post (single row map-element in a list of rows) (NULL: not a double post).
 */
function ocf_check_post($post, $topic_id = NULL, $poster = NULL)
{
    if (is_null($poster)) {
        $poster = get_member();
    }
    require_code('comcode_check');
    check_comcode($post, NULL, false, NULL, true);
    if (strlen($post) == 0) {
        warn_exit(do_lang_tempcode('POST_TOO_SHORT'));
    }
    require_code('ocf_groups');
    if (strlen($post) > ocf_get_member_best_group_property($poster, 'max_post_length_comcode')) {
        warn_exit(make_string_tempcode(escape_html(do_lang('_POST_TOO_LONG'))));
    }
    if (!is_null($topic_id)) {
        if (running_script('stress_test_loader')) {
            return NULL;
        }
        // Check this isn't the same as the last post here
        $last_posts = $GLOBALS['FORUM_DB']->query_select('f_posts', array('p_post', 'p_poster', 'p_ip_address'), array('p_topic_id' => $topic_id), 'ORDER BY p_time DESC,id DESC', 1);
        if (array_key_exists(0, $last_posts)) {
            if ($last_posts[0]['p_poster'] == $GLOBALS['OCF_DRIVER']->get_guest_id() && get_ip_address() != $last_posts[0]['p_ip_address']) {
                $last_posts[0]['p_poster'] = -1;
            }
            if ($last_posts[0]['p_poster'] == $poster && get_translated_text($last_posts[0]['p_post'], $GLOBALS['FORUM_DB']) == $post && get_param_integer('keep_debug_notifications', 0) != 1) {
                warn_exit(do_lang_tempcode('DOUBLE_POST_PREVENTED'));
            }
        }
        return $last_posts;
    }
    return NULL;
}
Example #11
0
/**
 * A page is not validated, so show a warning.
 *
 * @param  ID_TEXT		The zone the page is being loaded from
 * @param  ID_TEXT		The codename of the page
 * @param  tempcode		The edit URL (blank if no edit access)
 * @return tempcode		The warning
 */
function get_page_warning_details($zone, $codename, $edit_url)
{
    $warning_details = new ocp_tempcode();
    if (!has_specific_permission(get_member(), 'jump_to_unvalidated')) {
        access_denied('SPECIFIC_PERMISSION', 'jump_to_unvalidated');
    }
    $uv_warning = do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT');
    // Wear sun cream
    if (!$edit_url->is_empty()) {
        $menu_links = $GLOBALS['SITE_DB']->query('SELECT DISTINCT i_menu FROM ' . get_table_prefix() . 'menu_items WHERE ' . db_string_equal_to('i_url', $zone . ':' . $codename) . ' OR ' . db_string_equal_to('i_url', '_SEARCH:' . $codename));
        if (count($menu_links) != 0) {
            $menu_items_linking = new ocp_tempcode();
            foreach ($menu_links as $menu_link) {
                if (!$menu_items_linking->is_empty()) {
                    $menu_items_linking->attach(do_lang_tempcode('LIST_SEP'));
                }
                $menu_edit_url = build_url(array('page' => 'admin_menus', 'type' => 'edit', 'id' => $menu_link['i_menu']), get_module_zone('admin_menus'));
                $menu_items_linking->attach(hyperlink($menu_edit_url, $menu_link['i_menu'], false, true));
            }
            $uv_warning = do_lang_tempcode('UNVALIDATED_TEXT_STAFF', $menu_items_linking);
        }
    }
    $warning_details->attach(do_template('WARNING_TABLE', array('WARNING' => $uv_warning)));
    return $warning_details;
}
Example #12
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'max';
     $category_id = array_key_exists('param', $map) ? intval($map['param']) : db_get_first_id();
     $max = get_param_integer('max', array_key_exists('max', $map) ? intval($map['max']) : 30);
     $start = get_param_integer('start', 0);
     $root = array_key_exists('root', $map) && $map['root'] != '' ? intval($map['root']) : get_param_integer('root', NULL);
     $sort = array_key_exists('sort', $map) ? $map['sort'] : '';
     $search = array_key_exists('search', $map) ? $map['search'] : '';
     require_lang('catalogues');
     require_code('catalogues');
     require_code('feedback');
     require_css('catalogues');
     $select = NULL;
     if (!is_null($map) && array_key_exists('select', $map)) {
         require_code('ocfiltering');
         $select = ocfilter_to_sqlfragment($map['select'], 'e.id', 'catalogue_categories', 'cc_parent_id', 'cc_id', 'id');
     }
     $categories = $GLOBALS['SITE_DB']->query_select('catalogue_categories', array('*'), array('id' => $category_id), '', 1);
     if (!array_key_exists(0, $categories)) {
         return do_lang_tempcode('MISSING_RESOURCE');
     }
     $category = $categories[0];
     $catalogue_name = $category['c_name'];
     $catalogues = $GLOBALS['SITE_DB']->query_select('catalogues', array('*'), array('c_name' => $catalogue_name), '', 1);
     $catalogue = $catalogues[0];
     $tpl_set = array_key_exists('template_set', $map) ? $map['template_set'] : $catalogue_name;
     $display_type = array_key_exists('display_type', $map) ? intval($map['display_type']) : NULL;
     list($entry_buildup, , , ) = get_catalogue_category_entry_buildup(is_null($select) ? $category_id : NULL, $catalogue_name, $catalogue, 'CATEGORY', $tpl_set, $max, $start, $select, $root, $display_type, true, NULL, $search, $sort);
     return do_template('CATALOGUE_' . $tpl_set . '_CATEGORY_EMBED', array('ROOT' => strval($root), 'CATALOGUE' => $catalogue_name, 'ENTRIES' => $entry_buildup), NULL, false, 'CATALOGUE_DEFAULT_CATEGORY_EMBED');
 }
Example #13
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     unset($map);
     require_all_lang();
     require_css('adminzone');
     require_code('actionlog');
     $start = get_param_integer('sa_start', 0);
     $max = get_param_integer('sa_max', 10);
     $sortables = array('date_and_time' => do_lang_tempcode('DATE_TIME'), 'the_type' => do_lang_tempcode('ACTION'));
     $test = explode(' ', get_param('sa_sort', 'date_and_time DESC'), 2);
     if (count($test) == 1) {
         $test[1] = 'DESC';
     }
     list($sortable, $sort_order) = $test;
     if (strtoupper($sort_order) != 'ASC' && strtoupper($sort_order) != 'DESC' || !array_key_exists($sortable, $sortables)) {
         log_hack_attack_and_exit('ORDERBY_HACK');
     }
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'sa_sort';
     require_code('templates_results_table');
     $fields_title = results_field_title(array(do_lang_tempcode('USERNAME'), do_lang_tempcode('DATE_TIME'), do_lang_tempcode('ACTION'), do_lang_tempcode('PARAMETER_A'), do_lang_tempcode('PARAMETER_B')), $sortables, 'sa_sort', $sortable . ' ' . $sort_order);
     $max_rows = $max;
     //Don't want to encourage pagination (there's a better module they can go to) $GLOBALS['SITE_DB']->query_value('adminlogs','COUNT(*)');
     $rows = $GLOBALS['SITE_DB']->query_select('adminlogs', array('the_type', 'param_a', 'param_b', 'the_user', 'ip', 'date_and_time'), NULL, 'ORDER BY ' . $sortable . ' ' . $sort_order, $max, $start);
     $fields = new ocp_tempcode();
     foreach ($rows as $myrow) {
         $username = $GLOBALS['FORUM_DRIVER']->get_username($myrow['the_user']);
         if (is_null($username)) {
             $username = do_lang('UNKNOWN');
         }
         $date = get_timezoned_date($myrow['date_and_time']);
         if (!is_null($myrow['param_a'])) {
             $a = $myrow['param_a'];
         } else {
             $a = '';
         }
         if (!is_null($myrow['param_b'])) {
             $b = $myrow['param_b'];
         } else {
             $b = '';
         }
         require_code('templates_interfaces');
         $_a = tpl_crop_text_mouse_over($a, 8);
         $_b = tpl_crop_text_mouse_over($b, 15);
         $type_str = do_lang($myrow['the_type'], $_a, $_b, NULL, NULL, false);
         if (is_null($type_str)) {
             $type_str = $myrow['the_type'];
         }
         $test = actionlog_linkage($myrow['the_type'], $a, $b, $_a, $_b);
         if (!is_null($test)) {
             list($_a, $_b) = $test;
         }
         $ip = tpl_crop_text_mouse_over($myrow['ip'], 12);
         $fields->attach(results_entry(array(escape_html($username), escape_html($date), $type_str, $_a, $_b)));
     }
     return results_table(do_lang_tempcode('ACTIONS'), $start, 'sa_start', $max, 'sa_max', $max_rows, $fields_title, $fields, $sortables, $sortable, $sort_order, 'sa_sort', new ocp_tempcode(), NULL, NULL, 5);
 }
Example #14
0
/**
 * Get the tempcode for the form to add a banner, with the information passed along to it via the parameters already added in.
 *
 * @param  boolean			Whether to simplify the banner interface (for the point-store buy process)
 * @param  ID_TEXT			The name of the banner
 * @param  URLPATH			The URL to the banner image
 * @param  URLPATH			The URL to the site the banner leads to
 * @param  SHORT_TEXT		The caption of the banner
 * @param  LONG_TEXT			Any notes associated with the banner
 * @param  integer			The banners "importance modulus"
 * @range  1 max
 * @param  ?integer			The number of hits the banner may have (NULL: not applicable for this banner type)
 * @range  0 max
 * @param  SHORT_INTEGER	The type of banner (0=permanent, 1=campaign, 2=default)
 * @set    0 1 2
 * @param  ?TIME				The banner expiry date (NULL: never expires)
 * @param  ?ID_TEXT			The username of the banners submitter (NULL: current member)
 * @param  BINARY				Whether the banner has been validated
 * @param  ID_TEXT			The banner type (can be anything, where blank means 'normal')
 * @param  SHORT_TEXT		The title text for the banner (only used for text banners, and functions as the 'trigger text' if the banner type is shown inline)
 * @return tempcode			The input field tempcode
 */
function get_banner_form_fields($simplified = false, $name = '', $image_url = '', $site_url = '', $caption = '', $notes = '', $importancemodulus = 3, $campaignremaining = 50, $the_type = 1, $expiry_date = NULL, $submitter = NULL, $validated = 1, $b_type = '', $title_text = '')
{
    require_code('images');
    $fields = new ocp_tempcode();
    require_code('form_templates');
    $fields->attach(form_input_codename(do_lang_tempcode('CODENAME'), do_lang_tempcode('DESCRIPTION_BANNER_NAME'), 'name', $name, true));
    $fields->attach(form_input_line(do_lang_tempcode('DESTINATION_URL'), do_lang_tempcode('DESCRIPTION_BANNER_URL'), 'site_url', $site_url, false));
    // Blank implies iframe
    if (!$simplified) {
        $types = nice_get_banner_types($b_type);
        if ($types->is_empty()) {
            warn_exit(do_lang_tempcode('NO_CATEGORIES'));
        }
        $fields->attach(form_input_list(do_lang_tempcode('_BANNER_TYPE'), do_lang_tempcode('_DESCRIPTION_BANNER_TYPE'), 'b_type', $types, NULL, false, false));
    } else {
        $fields->attach(form_input_hidden('b_type', $b_type));
    }
    if (has_specific_permission(get_member(), 'full_banner_setup')) {
        $fields->attach(form_input_username(do_lang_tempcode('OWNER'), do_lang_tempcode('DESCRIPTION_SUBMITTER'), 'submitter', is_null($submitter) ? $GLOBALS['FORUM_DRIVER']->get_username(get_member()) : $submitter, false));
    }
    if (get_value('disable_staff_notes') !== '1') {
        $fields->attach(form_input_text(do_lang_tempcode('NOTES'), do_lang_tempcode('DESCRIPTION_NOTES'), 'notes', $notes, false));
    }
    if (has_specific_permission(get_member(), 'bypass_validation_midrange_content', 'cms_banners')) {
        if ($validated == 0) {
            $validated = get_param_integer('validated', 0);
            if ($validated == 1) {
                attach_message(do_lang_tempcode('WILL_BE_VALIDATED_WHEN_SAVING'));
            }
        }
        if (addon_installed('unvalidated')) {
            $fields->attach(form_input_tick(do_lang_tempcode('VALIDATED'), do_lang_tempcode('DESCRIPTION_VALIDATED'), 'validated', $validated == 1));
        }
    }
    $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('SOURCE_MEDIA'))));
    $fields->attach(form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_UPLOAD_BANNER'), 'file', false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images') . ',swf')));
    $fields->attach(form_input_line(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('IMAGE_URL')), do_lang_tempcode('DESCRIPTION_URL_BANNER'), 'image_url', $image_url, false));
    $fields->attach(form_input_line_comcode(do_lang_tempcode('BANNER_TITLE_TEXT'), do_lang_tempcode('DESCRIPTION_BANNER_TITLE_TEXT'), 'title_text', $title_text, false));
    $fields->attach(form_input_line_comcode(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_BANNER_DESCRIPTION'), 'caption', $caption, false));
    $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('DEPLOYMENT_DETERMINATION'))));
    if (has_specific_permission(get_member(), 'full_banner_setup')) {
        $radios = new ocp_tempcode();
        $radios->attach(form_input_radio_entry('the_type', strval(BANNER_PERMANENT), $the_type == BANNER_PERMANENT, do_lang_tempcode('BANNER_PERMANENT')));
        $radios->attach(form_input_radio_entry('the_type', strval(BANNER_CAMPAIGN), $the_type == BANNER_CAMPAIGN, do_lang_tempcode('BANNER_CAMPAIGN')));
        $radios->attach(form_input_radio_entry('the_type', strval(BANNER_DEFAULT), $the_type == BANNER_DEFAULT, do_lang_tempcode('BANNER_DEFAULT')));
        $fields->attach(form_input_radio(do_lang_tempcode('DEPLOYMENT_AGREEMENT'), do_lang_tempcode('DESCRIPTION_BANNER_TYPE'), 'the_type', $radios));
        $fields->attach(form_input_integer(do_lang_tempcode('HITS_ALLOCATED'), do_lang_tempcode('DESCRIPTION_HITS_ALLOCATED'), 'campaignremaining', $campaignremaining, false));
        $total_importance = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT SUM(importance_modulus) FROM ' . get_table_prefix() . 'banners WHERE ' . db_string_not_equal_to('name', $name));
        if (is_null($total_importance)) {
            $total_importance = 0;
        }
        $fields->attach(form_input_integer(do_lang_tempcode('IMPORTANCE_MODULUS'), do_lang_tempcode('DESCRIPTION_IMPORTANCE_MODULUS', strval($total_importance), strval($importancemodulus)), 'importancemodulus', $importancemodulus, true));
    }
    $fields->attach(form_input_date(do_lang_tempcode('EXPIRY_DATE'), do_lang_tempcode('DESCRIPTION_EXPIRY_DATE'), 'expiry_date', true, is_null($expiry_date), true, $expiry_date, 2));
    return $fields;
}
Example #15
0
 /**
  * Find whether this preview hook applies.
  *
  * @return array			Quartet: Whether it applies, the attachment ID type, whether the forum DB is used [optional], list of fields to limit to [optional]
  */
 function applies()
 {
     require_lang('ocf');
     $member_id = get_param_integer('id', get_member());
     $applies = get_param('page', '') == 'members' && post_param('signature', NULL) !== NULL;
     if ($applies) {
         require_code('ocf_groups');
         $max_sig_length = ocf_get_member_best_group_property($member_id, 'max_sig_length_comcode');
         if (strlen(post_param('post', '')) > $max_sig_length) {
             warn_exit(do_lang_tempcode('SIGNATURE_TOO_BIG'));
         }
     }
     return array($applies, 'ocf_signature', true, array('post'));
 }
/**
 * Put the contents of a page inside an iframe. This is typically used when a page is being used to traverse a result-set that spans multiple screens.
 *
 * @param  tempcode		The title
 * @param  ?integer		The time between refreshes (NULL: do not refresh)
 * @param  ?mixed			Data. A refresh will only happen if an AJAX-check indicates this data has changed (NULL: no check)
 * @return ?tempcode		The page output to finish off our current page stream such that it will spawn the iframe (NULL: not internalised)
 */
function internalise_own_screen($title, $refresh_time = NULL, $refresh_if_changed = NULL)
{
    if (get_value('no_frames') === '1' || get_param_integer('no_frames', 0) == 1 || get_param_integer('keep_no_frames', 0) == 1) {
        return NULL;
    }
    if (!has_js()) {
        return NULL;
    }
    // We need JS to make this a seamless process
    if (strpos(ocp_srv('REQUEST_URI'), '/iframe.php') !== false) {
        return NULL;
    }
    // This is already in the iframe
    require_javascript('javascript_ajax');
    require_javascript('javascript_iframe_screen');
    $url = find_script('iframe') . '?zone=' . rawurlencode(get_zone_name()) . '&wide_high=1&utheme=' . rawurlencode($GLOBALS['FORUM_DRIVER']->get_theme());
    foreach (array_merge($_GET, $_POST) as $key => $param) {
        if (!is_string($param)) {
            continue;
        }
        if (substr($key, 0, 5) == 'keep_' && skippable_keep($key, $param)) {
            continue;
        }
        if (get_magic_quotes_gpc()) {
            $param = stripslashes($param);
        }
        $url .= '&' . $key . '=' . urlencode($param);
    }
    if (!is_null($refresh_if_changed)) {
        require_javascript('javascript_sound');
        $change_detection_url = find_script('change_detection') . '?whatever=1';
        foreach ($_GET as $key => $param) {
            if (!is_string($param)) {
                continue;
            }
            if (substr($key, 0, 5) == 'keep_' && skippable_keep($key, $param)) {
                continue;
            }
            if (get_magic_quotes_gpc()) {
                $param = stripslashes($param);
            }
            $change_detection_url .= '&' . $key . '=' . urlencode($param);
        }
    } else {
        $refresh_if_changed = '';
        $change_detection_url = '';
    }
    return do_template('IFRAME_SCREEN', array('_GUID' => '06554eb227428fd5c648dee3c5b38185', 'TITLE' => $title, 'REFRESH_IF_CHANGED' => md5(serialize($refresh_if_changed)), 'CHANGE_DETECTION_URL' => $change_detection_url, 'REFRESH_TIME' => is_null($refresh_time) ? '' : strval($refresh_time), 'IFRAME_URL' => $url));
}
/**
 * @license		http://opensource.org/licenses/cpal_1.0 Common Public Attribution License
 * @copyright	ocProducts Ltd
 * @package		activity_feed
 */
function activities_addon_syndicate_described_activity($a_language_string_code = '', $a_label_1 = '', $a_label_2 = '', $a_label_3 = '', $a_pagelink_1 = '', $a_pagelink_2 = '', $a_pagelink_3 = '', $a_addon = '', $a_is_public = 1, $a_member_id = NULL, $sitewide_too = false, $a_also_involving = NULL)
{
    require_code('activities');
    require_lang('activities');
    if (get_db_type() == 'xml' && get_param_integer('keep_testing_logging', 0) != 1) {
        return NULL;
    }
    $stored_id = 0;
    if (is_null($a_member_id)) {
        $a_member_id = get_member();
    }
    if (is_guest($a_member_id)) {
        return NULL;
    }
    $go = array('a_language_string_code' => $a_language_string_code, 'a_label_1' => $a_label_1, 'a_label_2' => $a_label_2, 'a_label_3' => $a_label_3, 'a_is_public' => $a_is_public);
    $stored_id = mixed();
    // Check if this has been posted previously (within the last 10 minutes) to
    // stop spamming but allow generalised repeat status messages.
    $test = $GLOBALS['SITE_DB']->query_select('activities', array('a_language_string_code', 'a_label_1', 'a_label_2', 'a_label_3', 'a_is_public'), NULL, 'WHERE a_time>' . strval(time() - 600), 1);
    if (!array_key_exists(0, $test) || $test[0] != $go || running_script('execute_temp')) {
        // Log the activity
        $row = $go + array('a_member_id' => $a_member_id, 'a_also_involving' => $a_also_involving, 'a_pagelink_1' => $a_pagelink_1, 'a_pagelink_2' => $a_pagelink_2, 'a_pagelink_3' => $a_pagelink_3, 'a_time' => time(), 'a_addon' => $a_addon, 'a_is_public' => $a_is_public);
        $stored_id = $GLOBALS['SITE_DB']->query_insert('activities', $row, true);
        // Update the latest activity file
        log_newest_activity($stored_id, 1000);
        // External places
        if ($a_is_public == 1 && !$GLOBALS['IS_ACTUALLY_ADMIN']) {
            $dests = find_all_hooks('systems', 'syndication');
            foreach (array_keys($dests) as $hook) {
                require_code('hooks/systems/syndication/' . $hook);
                $ob = object_factory('Hook_Syndication_' . $hook);
                if ($ob->is_available()) {
                    $ob->syndicate_user_activity($a_member_id, $row);
                    if ($sitewide_too && has_specific_permission(get_member(), 'syndicate_site_activity') && post_param_integer('syndicate_this', 0) == 1) {
                        $ob->syndicate_site_activity($row);
                    }
                }
            }
        }
        list($message) = render_activity($row, false);
        require_code('notifications');
        $username = $GLOBALS['FORUM_DRIVER']->get_username($a_member_id);
        $subject = do_lang('ACTIVITY_NOTIFICATION_MAIL_SUBJECT', get_site_name(), $username, html_entity_decode(strip_tags($message->evaluate()), ENT_QUOTES, get_charset()));
        $mail = do_lang('ACTIVITY_NOTIFICATION_MAIL', comcode_escape(get_site_name()), comcode_escape($username), array('[semihtml]' . $message->evaluate() . '[/semihtml]'));
        dispatch_notification('activity', strval($a_member_id), $subject, $mail);
    }
    return $stored_id;
}
Example #18
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     $param = array_key_exists('param', $map) ? intval($map['param']) : -1;
     if ($param == -1) {
         $param = get_param_integer('poll_id', $param);
     }
     $zone = array_key_exists('zone', $map) ? $map['zone'] : get_module_zone('polls');
     require_css('side_blocks');
     require_css('polls');
     require_lang('polls');
     if (get_value('no_frames') === '1') {
         require_code('polls');
         return poll_script(true, $param);
     }
     return do_template('BLOCK_MAIN_POLL_IFRAME', array('RAND' => strval(mt_rand(0, 100000)), 'PARAM' => strval($param), 'ZONE' => $zone));
 }
Example #19
0
 /**
  * Find whether this preview hook applies.
  *
  * @return array			A pair: The preview, the updated post Comcode
  */
 function applies()
 {
     $member_id = get_param_integer('id', get_member());
     $applies = get_param('page', '') == 'admin_ocf_welcome_emails';
     if ($applies) {
         require_lang('ocf');
         require_code('mail');
         $subject_tag = post_param('subject');
         $message_raw = do_template('NEWSLETTER_DEFAULT', array('CONTENT' => post_param('text'), 'LANG' => get_site_default_lang()));
         $to = $GLOBALS['FORUM_DRIVER']->get_member_email_address(get_member());
         if ($to == '') {
             $to = get_option('staff_address');
         }
         mail_wrap($subject_tag, $message_raw->evaluate(get_site_default_lang()), array($to), $GLOBALS['FORUM_DRIVER']->get_username(get_member()), '', '', 3, NULL, false, get_member(), true);
     }
     return array($applies, NULL);
 }
Example #20
0
/**
 * Shows an HTML page of all authors clickably.
 */
function authors_script()
{
    require_lang('authors');
    global $NON_CANONICAL_PARAMS;
    $NON_CANONICAL_PARAMS[] = 'max';
    $start = get_param_integer('start', 0);
    $max = get_param_integer('max', 300);
    $author_fields = $GLOBALS['SITE_DB']->query('SELECT m_name,m_table FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'db_meta WHERE m_name LIKE \'' . db_encode_like('%author') . '\'');
    $rows = array();
    foreach ($author_fields as $field) {
        if ($field['m_table'] != 'addons' && $field['m_table'] != 'blocks' && $field['m_table'] != 'modules') {
            $rows_new = $GLOBALS['SITE_DB']->query('SELECT DISTINCT ' . $field['m_name'] . ' AS author FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . $field['m_table'] . ' WHERE ' . db_string_not_equal_to($field['m_name'], '') . ' ORDER BY ' . $field['m_name'], $max + $start);
            foreach ($rows_new as $a) {
                if (!array_key_exists($a['author'], $rows) || $field['m_table'] == 'authors') {
                    $rows[$a['author']] = $field['m_table'];
                }
            }
        }
    }
    $rows = array_unique($rows);
    $field_name = get_param('field_name');
    $content = new ocp_tempcode();
    $i = 0;
    foreach ($rows as $author => $table) {
        if ($i >= $start && $i < $start + $max) {
            if ($table == 'authors') {
                $content->attach(do_template('AUTHOR_POPUP_WINDOW_DEFINED', array('_GUID' => 'cffa9926cebd3ec2920677266a3299ea', 'FIELD_NAME' => $field_name, 'AUTHOR' => $author)));
            } else {
                $content->attach(do_template('AUTHOR_POPUP_WINDOW_UNDEFINED', array('_GUID' => '6210be6d1eef4bc2bda7f49947301f97', 'FIELD_NAME' => $field_name, 'AUTHOR' => $author)));
            }
        }
        $i++;
    }
    if ($content->is_empty()) {
        $content = paragraph(do_lang_tempcode('NO_ENTRIES'), 'dfids09fi;lk;3');
    }
    if ($i >= $start + $max) {
        $keep = symbol_tempcode('KEEP');
        $next_link = find_script('authors') . '?field_name=' . urlencode($field_name) . '&start=' . strval($start + $max) . '&max=' . strval($max) . $keep->evaluate();
    } else {
        $next_link = NULL;
    }
    $echo = do_template('STYLED_HTML_WRAP', array('_GUID' => 'ab8d8c9d276530d82ddd84202aacf32f', 'TITLE' => do_lang_tempcode('CHOOSE_AUTHOR'), 'NEXT_LINK' => $next_link, 'CONTENT' => $content));
    $echo->evaluate_echo();
}
Example #21
0
 /**
  * Standard modular run function for change_detection hooks. They see if their own something has changed in comparison to sample data.
  *
  * @param  string			The sample data, serialised and then MD5'd
  * @return boolean		Whether the something has changed
  */
 function run($data)
 {
     if (get_param('type', 'misc') == 'misc') {
         require_code('tickets');
         require_code('tickets2');
         $ticket_type = get_param_integer('ticket_type', NULL);
         $tickets = get_tickets(get_member(), $ticket_type);
         return md5(serialize($tickets)) != $data;
     }
     $id = get_param('id', NULL);
     require_code('tickets');
     require_code('tickets2');
     $forum = 0;
     $topic_id = 0;
     $ticket_type = 0;
     $_comments = get_ticket_posts($id, $forum, $topic_id, $ticket_type);
     return md5(serialize($_comments)) != $data;
 }
Example #22
0
 /**
  * Standard modular run function for snippet hooks. Generates XHTML to insert into a page using AJAX.
  *
  * @return tempcode  The snippet
  */
 function run()
 {
     if (function_exists('set_time_limit')) {
         @set_time_limit(0);
     }
     require_code('files');
     require_code('files2');
     $size = 0;
     $max_size = get_param_integer('max_size') * 1024 * 1024;
     $files = get_directory_contents(get_custom_file_base());
     foreach ($files as $file) {
         $filesize = filesize(get_custom_file_base() . '/' . $file);
         if ($filesize < $max_size) {
             $size += $filesize;
         }
     }
     return make_string_tempcode(clean_file_size($size));
 }
Example #23
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     require_code('templates_donext');
     require_code('menus');
     require_all_lang();
     $type = get_param('type', 'misc');
     if ((!has_specific_permission(get_member(), 'avoid_simplified_adminzone_look') || $GLOBALS['FORUM_DRIVER']->is_super_admin(get_member())) && num_staff_icons() < MIN_STAFF_ICONS_BEFORE_COLLAPSE) {
         if ($type == 'misc') {
             return do_next_manager_admin_simplified();
         }
     }
     // Warning about whether the Setup Wizard still needs running
     if (get_param_integer('cancel_sw_warn', 0) == 1 || !addon_installed('setupwizard')) {
         set_value('setup_wizard_completed', '1');
     } else {
         $_done_sw_once = get_value('setup_wizard_completed');
         $done_sw_once = !is_null($_done_sw_once);
         if (!$done_sw_once && get_param('page', '') != 'admin_setupwizard' && has_actual_page_access(get_member(), 'admin_setupwizard')) {
             $setup_wizard_url = build_url(array('page' => 'admin_setupwizard'), get_module_zone('admin_setupwizard'));
             $cancel_sw_url = get_self_url(false, false, array('cancel_sw_warn' => 1));
             attach_message(do_lang_tempcode('SETUP_WIZARD_NOT_RUN', escape_html($setup_wizard_url->evaluate()), escape_html($cancel_sw_url->evaluate())), 'notice');
         }
     }
     switch ($type) {
         case 'misc':
             return do_next_manager_hooked('ADMIN_ZONE', 'DOC_ADMIN_ZONE', '');
         case 'structure':
             return do_next_manager_hooked('STRUCTURE', 'DOC_STRUCTURE', 'structure');
         case 'usage':
             return do_next_manager_hooked('USAGE', 'DOC_USAGE', 'usage');
         case 'style':
             return do_next_manager_hooked('STYLE', 'DOC_STYLE', 'style');
         case 'setup':
             return do_next_manager_hooked('SETUP', 'DOC_SETUP', 'setup');
         case 'tools':
             return do_next_manager_hooked('TOOLS', 'DOC_TOOLS', 'tools');
         case 'security':
             return do_next_manager_hooked('SECURITY', 'DOC_SECURITY', 'security');
         case 'search':
             return $this->search();
     }
     return new ocp_tempcode();
 }
Example #24
0
/**
 * Output the trackback script and handle trackbacks.
 */
function trackback_script()
{
    if (get_option('is_on_trackbacks') == '0') {
        return;
    }
    require_lang('trackbacks');
    header('Content-type: text/xml');
    $page = get_param('page');
    $id = get_param_integer('id');
    $mode = either_param('__mode', 'none');
    $allow_trackbacks = true;
    $hooks = find_all_hooks('systems', 'trackback');
    foreach (array_keys($hooks) as $hook) {
        if ($hook == $page) {
            require_code('hooks/systems/trackback/' . filter_naughty_harsh($hook));
            $object = object_factory('Hook_trackback_' . filter_naughty_harsh($hook), true);
            if (is_null($object)) {
                continue;
            }
            $allow_trackbacks = $object->run($id);
            break;
        }
    }
    if ($mode == 'rss') {
        //List all the trackbacks to the specified page
        $xml = get_trackbacks($page, strval($id), $allow_trackbacks, 'xml');
    } else {
        $time = get_param_integer('time');
        if ($time > time() - 60 * 5) {
            exit;
        }
        // Trackback link intentionally goes stale after 5 minutes, so it can't be statically stored and spam hammered
        //Add a trackback for the specified page
        $output = actualise_post_trackback($allow_trackbacks, $page, strval($id));
        if ($output) {
            $xml = do_template('TRACKBACK_XML_NO_ERROR', array());
        } else {
            $xml = do_template('TRACKBACK_XML_ERROR', array('_GUID' => 'ac5e34aeabf92712607e62e062407861', 'TRACKBACK_ERROR' => do_lang_tempcode('TRACKBACK_ERROR')));
        }
    }
    $echo = do_template('TRACKBACK_XML_WRAPPER', array('_GUID' => 'cd8d057328569803a6cca9f8d37a0ac8', 'XML' => $xml));
    $echo->evaluate_echo();
}
 /**
  * This will get the XML file from ocportal.com.
  *
  * @param  ?ID_TEXT		The ID to do under (NULL: root)
  * @return string			The XML file
  */
 function get_file($id)
 {
     $stub = get_param_integer('localhost', 0) == 1 ? get_base_url() : 'http://ocportal.com';
     $v = 'Version ' . float_to_raw_string(ocp_version_number(), 1);
     if (!is_null($id)) {
         $v = $id;
     }
     $url = $stub . '/data/ajax_tree.php?hook=choose_download&id=' . rawurlencode($v) . '&file_type=tar';
     require_code('character_sets');
     $contents = http_download_file($url);
     $utf = $GLOBALS['HTTP_CHARSET'] == 'utf-8';
     // We have to use 'U' in the regexp to work around a Chrome parser bug (we can't rely on convert_to_internal_encoding being 100% correct)
     require_code('character_sets');
     $contents = convert_to_internal_encoding($contents);
     $contents = preg_replace('#^\\s*\\<' . '\\?xml version="1.0" encoding="[^"]*"\\?' . '\\>\\<request\\>#' . ($utf ? 'U' : ''), '', $contents);
     $contents = preg_replace('#</request>#' . ($utf ? 'U' : ''), '', $contents);
     $contents = preg_replace('#<category [^>]*has_children="false"[^>]*>[^>]*</category>#' . ($utf ? 'U' : ''), '', $contents);
     $contents = preg_replace('#<category [^>]*title="Manual install required"[^>]*>[^>]*</category>#' . ($utf ? 'U' : ''), '', $contents);
     return $contents;
 }
Example #26
0
 /**
  * Standard modular run function for snippet hooks. Generates XHTML to insert into a page using AJAX.
  *
  * @return tempcode  The snippet
  */
 function run()
 {
     $member_id_viewing = get_member();
     $member_id_of = get_param_integer('member_id');
     $hook = filter_naughty_harsh(get_param('tab'));
     require_lang('ocf');
     // HACKHACK
     $_GET['page'] = 'members';
     $_GET['type'] = 'view';
     $_GET['id'] = strval($member_id_of);
     unset($_GET['snippet']);
     unset($_GET['member_id']);
     unset($_GET['tab']);
     unset($_GET['url']);
     unset($_GET['title']);
     unset($_GET['utheme']);
     global $RELATIVE_PATH, $ZONE;
     $RELATIVE_PATH = get_module_zone('members');
     $zones = $GLOBALS['SITE_DB']->query_select('zones', array('*'), array('zone_name' => $RELATIVE_PATH), '', 1);
     $ZONE = $zones[0];
     global $PAGE_NAME_CACHE;
     $PAGE_NAME_CACHE = 'members';
     global $RUNNING_SCRIPT_CACHE;
     $RUNNING_SCRIPT_CACHE = array('index' => true);
     require_code('hooks/systems/profiles_tabs/' . $hook);
     $ob = object_factory('Hook_Profiles_Tabs_' . $hook);
     if ($ob->is_active($member_id_of, $member_id_viewing)) {
         global $CSSS, $JAVASCRIPTS;
         $CSSS = array();
         $JAVASCRIPTS = array();
         $ret = $ob->render_tab($member_id_of, $member_id_viewing);
         $out = new ocp_tempcode();
         $out->attach(symbol_tempcode('CSS_TEMPCODE'));
         $out->attach(symbol_tempcode('JS_TEMPCODE'));
         $out->attach($ret[1]);
         return $out;
     }
     return do_template('INLINE_WIP_MESSAGE', array('MESSAGE' => do_lang_tempcode('INTERNAL_ERROR')));
 }
Example #27
0
/**
 * AJAX script for returning realtime-rain data.
 */
function realtime_rain_script()
{
    header("Cache-Control: no-cache, must-revalidate");
    // HTTP/1.1
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    // Date in the past
    @ini_set('ocproducts.xss_detect', '0');
    header('Content-Type: text/xml');
    echo '<?xml version="1.0" encoding="' . get_charset() . '"?' . '>';
    echo '<request><result>';
    require_code('realtime_rain');
    require_lang('realtime_rain');
    $time_now = time();
    $from = get_param_integer('from', $time_now - 10);
    $to = get_param_integer('to', $time_now);
    if (get_param_integer('keep_realtime_test', 0) == 1) {
        $types = array('post', 'news', 'recommend', 'polls', 'ecommerce', 'actionlog', 'security', 'chat', 'stats', 'join', 'calendar', 'search', 'point_charges', 'banners', 'point_gifts');
        shuffle($types);
        $events = array();
        $cnt = count($types);
        for ($i = 0; $i < max($cnt, 5); $i++) {
            $timestamp = mt_rand($from, $to);
            $type = array_pop($types);
            $event = rain_get_special_icons(get_ip_address(), $timestamp) + array('TYPE' => $type, 'FROM_MEMBER_ID' => NULL, 'TO_MEMBER_ID' => NULL, 'TITLE' => 'Test', 'IMAGE' => rain_get_country_image(get_ip_address()), 'TIMESTAMP' => strval($timestamp), 'RELATIVE_TIMESTAMP' => strval($timestamp - $from), 'TICKER_TEXT' => NULL, 'URL' => NULL, 'IS_POSITIVE' => $type == 'ecommerce' || $type == 'join', 'IS_NEGATIVE' => $type == 'security' || $type == 'point_charges', 'FROM_ID' => NULL, 'TO_ID' => NULL, 'GROUP_ID' => 'example_' . strval(mt_rand(0, 4)));
            $event['SPECIAL_ICON'] = 'email-icon';
            $event['MULTIPLICITY'] = '10';
            $events[] = $event;
        }
    } else {
        $events = get_realtime_events($from, $to);
    }
    shuffle($events);
    $out = new ocp_tempcode();
    foreach ($events as $event) {
        $out->attach(do_template('REALTIME_RAIN_BUBBLE', $event));
    }
    $out->evaluate_echo();
    echo '</result></request>';
}
Example #28
0
/**
 * Log permission checks to the permission_checks.log file, if it exists.
 *
 * @param  MEMBER         The user checking against
 * @param  ID_TEXT        The function that was called to check a permission
 * @param  array          Parameters to this permission-checking function
 * @param  boolean        Whether the permission was held
 */
function handle_permission_check_logging($member, $op, $params, $result)
{
    global $PERMISSION_CHECK_LOGGER, $PERMISSIONS_ALREADY_LOGGED, $SITE_INFO;
    if ($PERMISSION_CHECK_LOGGER === NULL) {
        $file_path = get_custom_file_base() . '/data_custom/permissioncheckslog.php';
        if ((!isset($SITE_INFO['no_extra_logs']) || $SITE_INFO['no_extra_logs'] == '0') && is_file($file_path) && is_writable_wrap($file_path)) {
            $PERMISSION_CHECK_LOGGER = fopen($file_path, 'at');
            if (!function_exists('get_self_url')) {
                require_code('tempcode');
                require_code('urls');
            }
            $self_url = get_self_url(true);
            if (!is_string($self_url)) {
                $self_url = get_self_url_easy();
            }
            // A weirdness can happen here. If some kind of fatal error happens then output buffers can malfunction making it impossible to use Tempcode as above. So we fall back to this. (This function may be called in a fatal error due to the 'display_php_errors' permissions).
            fwrite($PERMISSION_CHECK_LOGGER, chr(10) . chr(10) . date('Y/m/d h:m:i') . ' -- ' . $self_url . ' -- ' . $GLOBALS['FORUM_DRIVER']->get_username(get_member()) . chr(10));
        } else {
            $PERMISSION_CHECK_LOGGER = false;
        }
    }
    static $fbe = NULL;
    if ($fbe === NULL) {
        $fbe = function_exists('fb');
    }
    if ($PERMISSION_CHECK_LOGGER === false && (!$fbe || get_param_integer('keep_firephp', 0) == 0)) {
        return;
    }
    $sz = serialize(array($member, $op, $params));
    if (array_key_exists($sz, $PERMISSIONS_ALREADY_LOGGED)) {
        return;
    }
    $PERMISSIONS_ALREADY_LOGGED[$sz] = 1;
    if ($result) {
        return;
    }
    require_code('permissions2');
    _handle_permission_check_logging($member, $op, $params, $result);
}
Example #29
0
function set_coordinates()
{
    header('Content-Type: text/plain');
    $_coords = get_param('coord', '');
    $member_id = get_param_integer('mid', get_member());
    //prevent hack attepts
    if ($member_id != get_member()) {
        return;
    }
    $coords = explode('_', $_coords);
    $latitude_cpf_id = $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' => 'ocp_latitude'));
    $longitude_cpf_id = $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' => 'ocp_longitude'));
    //are there latitude and longtitude custom profile fields ?
    if (is_null($longitude_cpf_id) || is_null($latitude_cpf_id)) {
        return;
    }
    //check for inputed coordinates
    if (!is_array($coords) || !isset($coords[0]) || !isset($coords[1])) {
        return;
    }
    $GLOBALS['FORUM_DB']->query_update('f_member_custom_fields', array('field_' . $latitude_cpf_id => strval($coords[0]), 'field_' . $longitude_cpf_id => strval($coords[1])), array('mf_member_id' => $member_id));
}
Example #30
0
 /**
  * Standard modular render function for profile tab hooks.
  *
  * @param  MEMBER			The ID of the member who is being viewed
  * @param  MEMBER			The ID of the member who is doing the viewing
  * @param  boolean		Whether to leave the tab contents NULL, if tis hook supports it, so that AJAX can load it later
  * @return array			A triple: The tab title, the tab contents, the suggested tab order
  */
 function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false)
 {
     $title = do_lang_tempcode('PERSONAL_TOPICS_INBOX');
     $order = 80;
     if ($leave_to_ajax_if_possible) {
         return array($title, NULL, $order);
     }
     require_code('ocf_forumview');
     require_code('ocf_topics');
     require_code('ocf_general');
     require_lang('ocf');
     $id = NULL;
     $current_filter_cat = get_param('category', '');
     $root = get_param_integer('keep_forum_root', db_get_first_id());
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'start';
     $max = get_param_integer('max', 10);
     $start = get_param_integer('start', get_param_integer('kfs', 0));
     $root = db_get_first_id();
     list($content, , , ) = ocf_render_forumview($id, $current_filter_cat, $max, $start, $root, $member_id_of);
     return array($title, $content, $order);
 }