/**
* Standard modular run function.
*
* @param MEMBER The ID of the member we are getting link hooks for
* @return array List of tuples for results. Each tuple is: type,title,url
*/
function run($member_id)
{
if (!has_zone_access(get_member(), 'adminzone') && $member_id !== get_member()) {
return array();
}
require_code('ocf_join');
if (!referrer_is_qualified($member_id)) {
return array();
}
require_lang('referrals');
$keep = symbol_tempcode('KEEP');
return array(array('usage', do_lang_tempcode('REFERRALS'), find_script('referrer_report') . '?member_id=' . strval($member_id) . $keep->evaluate()));
}
/**
* 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));
}
/**
* 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)
{
$GLOBALS['FEED_URL'] = find_script('backend') . '?mode=activities&filter=' . strval($member_id_of);
require_lang('activities');
$title = do_lang_tempcode('ACTIVITIES_TITLE');
$order = 70;
// Need to declare these here as the Tempcode engine can't look as deep, into a loop (I think), as it would need to, to find the block declaring the dependency
require_css('activities');
require_javascript('javascript_activities_state');
require_javascript('javascript_activities');
require_javascript('javascript_jquery');
require_javascript('javascript_base64');
// Allow user to link up things for syndication
$syndications = array();
if ($member_id_of == $member_id_viewing) {
$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()) {
if (either_param('syndicate_stop__' . $hook, NULL) !== NULL) {
$ob->auth_unset($member_id_of);
} elseif (either_param('syndicate_start__' . $hook, NULL) !== NULL) {
$url_map = array('page' => '_SELF', 'type' => 'view', 'id' => $member_id_of, 'oauth_in_progress' => 1);
$url_map['syndicate_start__' . $hook] = 1;
$oauth_url = build_url($url_map, '_SELF', NULL, false, false, false, 'tab__activities');
$ob->auth_set($member_id_of, $oauth_url);
} elseif (running_script('index') && !$leave_to_ajax_if_possible && $ob->auth_is_set($member_id_of) && either_param('oauth_in_progress', NULL) === NULL && !$GLOBALS['IS_ACTUALLY_ADMIN']) {
/* running_script('index') won't work currently due to execution contexts, and it is never non-AJAX, and it's probably not needed anyway
// Do a refresh to make sure the token is updated
$url_map=array('page'=>'_SELF','type'=>'view','id'=>$member_id_of,'oauth_in_progress'=>1);
$url_map['syndicate_start__'.$hook]=1;
$oauth_url=build_url($url_map,'_SELF',NULL,false,false,false,'tab__activities');
$ob->auth_set($member_id_of,$oauth_url);
*/
}
$syndications[$hook] = array('SYNDICATION_IS_SET' => $ob->auth_is_set($member_id_of), 'SYNDICATION_SERVICE_NAME' => $ob->get_service_name());
}
}
}
if ($leave_to_ajax_if_possible) {
return array($title, NULL, $order);
}
$content = do_template('OCF_MEMBER_PROFILE_ACTIVITIES', array('MEMBER_ID' => strval($member_id_of), 'SYNDICATIONS' => $syndications));
return array($title, $content, $order);
}
/**
* Helper function to work out a results browser URL.
*
* @param array Map of GET array segments to use (others will be added by this function)
* @param array Map of POST array segments (relayed as GET) to use
* @param ?ID_TEXT The page type this browser is browsing through (e.g. 'category') (NULL: none)
* @param ?mixed The virtual root category this browser uses (NULL: no such concept for our results browser)
* @param ?mixed The category ID we are browsing in (NULL: not applicable)
* @param boolean Whether to keep get data when browsing through
* @param ID_TEXT Hash component to URL
* @return mixed The URL
*/
function _build_results_browser_cat_url($url_array, $post_array, $type, $root, $category_id, $keep_all, $hash)
{
if (!is_null($category_id)) {
if (!is_string($category_id)) {
$category_id = strval($category_id);
}
}
$url_array = array_merge($url_array, $post_array);
if (!is_null($type)) {
$url_array['type'] = $type;
}
if (!is_null($root)) {
$url_array['root'] = $root;
}
if (!is_null($category_id)) {
$url_array['id'] = $category_id;
$url_array['kfs' . $category_id] = NULL;
// For OCF. We don't need this anymore because we're using 'start' explicitly here
}
if (strpos(ocp_srv('REQUEST_URI'), '/iframe.php') !== false) {
$cat_url = make_string_tempcode(find_script('iframe') . '?zone=' . get_zone_name());
if ($keep_all) {
$url_array = array_merge($_GET, $_POST, $url_array);
}
foreach ($url_array as $key => $param) {
if ($key == 'wide_high') {
continue;
}
if (is_array($param)) {
continue;
}
if (substr($key, 0, 5) == 'keep_' && skippable_keep($key, $param)) {
continue;
}
if ($param === '_SELF') {
$param = get_page_name();
}
if (get_magic_quotes_gpc()) {
$param = stripslashes($param);
}
if ($key != 'zone') {
$cat_url->attach('&' . $key . '=' . urlencode($param));
}
}
} else {
$cat_url = build_url($url_array, '_SELF', NULL, $keep_all, false, false, $hash);
}
return $cat_url;
}
/**
* Get tempcode for a Comcode rich-media attachment.
*
* @param ID_TEXT The attachment tag
* @set attachment attachment_safe attachment2
* @param array A map of the attributes (name=>val) for the tag
* @param array A map of the attachment properties (name=>val) for the attachment
* @param string A special identifier to mark where the resultant tempcode is going to end up (e.g. the ID of a post)
* @param MEMBER The member who is responsible for this Comcode
* @param boolean Whether to check as arbitrary admin
* @param object The database connection to use
* @param ?array A list of words to highlight (NULL: none)
* @param ?MEMBER The member we are running on behalf of, with respect to how attachments are handled; we may use this members attachments that are already within this post, and our new attachments will be handed to this member (NULL: member evaluating)
* @param boolean Whether to parse so as to create something that would fit inside a semihtml tag. It means we generate HTML, with Comcode written into it where the tag could never be reverse-converted (e.g. a block).
* @return tempcode The tempcode for the attachment
*/
function render_attachment($tag, $attributes, $attachment, $pass_id, $source_member, $as_admin, $connection, $highlight_bits = NULL, $on_behalf_of_member = NULL, $semiparse_mode = false)
{
require_code('comcode_renderer');
$extension = get_file_extension($attachment['a_original_filename']);
require_code('mime_types');
$mime_type = get_mime_type($extension);
$attachment['CLEAN_SIZE'] = clean_file_size($attachment['a_file_size']);
$attachment['MIME_TYPE'] = $mime_type;
$attachment['PASS_ID'] = intval($pass_id) < 0 ? strval(mt_rand(0, 10000)) : $pass_id;
$attachment['SCRIPT'] = find_script('attachment');
$attachment['RAND'] = strval(mt_rand(0, 32000));
if ($connection->connection_write != $GLOBALS['SITE_DB']->connection_write) {
$attachment['SUP_PARAMS'] = '&forum_db=1';
$attachment['FORUM_DB_BIN'] = '1';
} else {
$attachment['SUP_PARAMS'] = '';
$attachment['FORUM_DB_BIN'] = '';
}
$type = trim(array_key_exists('type', $attributes) ? $attributes['type'] : 'auto');
$attachment['id'] = strval($attachment['id']);
$attachment['a_member_id'] = strval($attachment['a_member_id']);
$attachment['a_file_size'] = strval($attachment['a_file_size']);
$attachment['a_last_downloaded_time'] = is_null($attachment['a_last_downloaded_time']) ? '' : strval($attachment['a_last_downloaded_time']);
$attachment['a_add_time'] = strval($attachment['a_add_time']);
$attachment['a_num_downloads'] = integer_format($attachment['a_num_downloads']);
require_code('images');
$attachment['a_width'] = array_key_exists('width', $attributes) ? strval(intval($attributes['width'])) : '';
$attachment['a_height'] = array_key_exists('height', $attributes) ? strval(intval($attributes['height'])) : '';
if ($attachment['a_width'] == '' || $attachment['a_height'] == '') {
if (addon_installed('galleries') && is_video($attachment['a_original_filename']) && url_is_local($attachment['a_url'])) {
require_code('galleries2');
$vid_details = get_video_details(get_custom_file_base() . '/' . rawurldecode($attachment['a_url']), $attachment['a_original_filename'], true);
if ($vid_details !== false) {
list($_width, $_height, ) = $vid_details;
if ($attachment['a_width'] == '') {
$attachment['a_width'] = strval($_width);
}
if ($attachment['a_height'] == '') {
$attachment['a_height'] = strval($_height);
}
}
}
if ($attachment['a_width'] == '' || $attachment['a_height'] == '') {
if ($attachment['a_width'] == '') {
$attachment['a_width'] = '240';
}
if ($attachment['a_height'] == '') {
$attachment['a_height'] = '216';
}
}
}
$attachment['a_align'] = array_key_exists('align', $attributes) ? $attributes['align'] : 'left';
if (!array_key_exists('a_description', $attachment)) {
if (array_key_exists('description', $attributes)) {
$attachment['description'] = $attributes['description'];
}
if (!array_key_exists('description', $attachment)) {
$attachment['description'] = '';
}
$attachment['a_description'] = is_object($attachment['description']) ? $attachment['description'] : comcode_to_tempcode($attachment['description'], $source_member, $as_admin, 60, NULL, $connection, false, false, false, false, false, NULL, $on_behalf_of_member);
} else {
$attachment['a_description'] = comcode_to_tempcode($attachment['a_description'], $source_member, $as_admin, 60, NULL, $connection, false, false, false, false, false, NULL, $on_behalf_of_member);
}
$attachment['a_type'] = $type;
$attachment['a_thumb'] = array_key_exists('thumb', $attributes) ? $attributes['thumb'] : '1';
if ($attachment['a_thumb'] != '0') {
$attachment['a_thumb'] = '1';
}
$attachment['a_thumb_url'] = array_key_exists('thumb_url', $attributes) ? $attributes['thumb_url'] : $attachment['a_thumb_url'];
switch ($type) {
case 'email':
require_code('mail');
global $EMAIL_ATTACHMENTS;
if (url_is_local($attachment['a_url'])) {
$attachment['a_url'] = get_custom_base_url() . '/' . $attachment['a_url'];
}
$EMAIL_ATTACHMENTS[$attachment['a_url']] = $attachment['a_original_filename'];
$temp_tpl = new ocp_tempcode();
break;
case 'code':
$url = $attachment['a_url'];
if (url_is_local($url)) {
$url = get_custom_base_url() . '/' . $url;
}
//.........这里部分代码省略.........
请发表评论