/** * Standard modular run function. * * @return tempcode Results */ function run() { $dbs_bak = $GLOBALS['NO_DB_SCOPE_CHECK']; $GLOBALS['NO_DB_SCOPE_CHECK'] = true; // Find known paths $known_urls = array(); $urlpaths = $GLOBALS['SITE_DB']->query_select('db_meta', array('m_name', 'm_table'), array('m_type' => 'URLPATH')); $base_url = get_custom_base_url(); foreach ($urlpaths as $urlpath) { $ofs = $GLOBALS['SITE_DB']->query_select($urlpath['m_table'], array($urlpath['m_name'])); foreach ($ofs as $of) { $url = $of[$urlpath['m_name']]; if (url_is_local($url)) { $known_urls[rawurldecode($url)] = 1; } else { if (substr($url, 0, strlen($base_url)) == $base_url) { $known_urls[substr($url, strlen($base_url) + 1)] = 1; } } } } $all_files = $this->do_dir('uploads'); $orphaned = array(); foreach ($all_files as $file) { if (!array_key_exists($file, $known_urls)) { $orphaned[] = array('URL' => get_custom_base_url() . '/' . str_replace('%2F', '/', rawurlencode($file))); } } $GLOBALS['NO_DB_SCOPE_CHECK'] = $dbs_bak; return do_template('CLEANUP_ORPHANED_UPLOADS', array('_GUID' => '21049d738f67554cff0891d343c02ad3', 'FOUND' => $orphaned)); }
/** * Standard modular run function for award hooks. Renders a content box for an award/randomisation. * * @param array The database row for the content * @param ID_TEXT The zone to display in * @return tempcode Results */ function run($row, $zone) { $url = build_url(array('page' => 'news', 'type' => 'view', 'id' => $row['id']), $zone); $title = get_translated_tempcode($row['title']); $title_plain = get_translated_text($row['title']); $news_cat_rows = $GLOBALS['SITE_DB']->query_select('news_categories', array('nc_title', 'nc_img'), array('id' => $row['news_category']), '', 1); if (!array_key_exists(0, $news_cat_rows)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $news_cat_row = $news_cat_rows[0]; $category = get_translated_text($news_cat_row['nc_title']); $img = find_theme_image($news_cat_row['nc_img']); if ($row['news_image'] != '') { $img = $row['news_image']; if (url_is_local($img)) { $img = get_base_url() . '/' . $img; } } $news = get_translated_tempcode($row['news']); if ($news->is_empty()) { $news = get_translated_tempcode($row['news_article']); $truncate = true; } else { $truncate = false; } $author_url = addon_installed('authors') ? build_url(array('page' => 'authors', 'type' => 'misc', 'id' => $row['author']), get_module_zone('authors')) : new ocp_tempcode(); $author = $row['author']; require_css('news'); $seo_bits = seo_meta_get_for('news', strval($row['id'])); $map = array('_GUID' => 'jd89f893jlkj9832gr3uyg2u', 'TAGS' => get_loaded_tags('news', explode(',', $seo_bits[0])), 'TRUNCATE' => $truncate, 'AUTHOR' => $author, 'BLOG' => false, 'AUTHOR_URL' => $author_url, 'CATEGORY' => $category, 'IMG' => $img, 'NEWS' => $news, 'ID' => strval($row['id']), 'SUBMITTER' => strval($row['submitter']), 'DATE' => get_timezoned_date($row['date_and_time']), 'DATE_RAW' => strval($row['date_and_time']), 'FULL_URL' => $url, 'NEWS_TITLE' => $title, 'NEWS_TITLE_PLAIN' => $title_plain); if (get_option('is_on_comments') == '1' && !has_no_forum() && $row['allow_comments'] >= 1) { $map['COMMENT_COUNT'] = '1'; } return put_in_standard_box(do_template('NEWS_PIECE_SUMMARY', $map)); }
/** * Convert a field value to something renderable. * * @param array The field details * @param mixed The raw value * @param integer Position in fieldset * @param ?array List of fields the output is being limited to (NULL: N/A) * @return mixed Rendered field (tempcode or string) */ function render_field_value($field, $ev, $i, $only_fields) { if (is_object($ev)) { return $ev; } if ($ev == '') { return ''; } require_code('galleries'); require_code('galleries2'); require_code('transcoding'); $ev = transcode_video($ev, 'catalogue_efv_short', 'cv_value', NULL, NULL, NULL); $thumb_url = create_video_thumb($ev); if (substr($ev, 0, strlen(get_custom_base_url() . '/')) == get_custom_base_url() . '/') { $ev = substr($ev, strlen(get_custom_base_url() . '/')); } if (url_is_local($ev)) { $width = 600; $height = 400; $length = 0; } else { list($width, $height, $length) = get_video_details(get_custom_file_base() . '/' . rawurldecode($ev), basename($ev)); } return show_gallery_media($ev, $thumb_url, $width, $height, $length); }
/** * Standard modular run function for preview hooks. * * @return array A pair: The preview, the updated post Comcode */ function run() { require_code('uploads'); $urls = get_url('', 'file', 'uploads/iotds', 0, OCP_UPLOAD_IMAGE, true, '', 'file2'); if ($urls[0] == '') { if (!is_null(post_param_integer('id', NULL))) { $rows = $GLOBALS['SITE_DB']->query_select('iotds', array('url', 'thumb_url'), array('id' => post_param_integer('id')), '', 1); $urls = $rows[0]; $url = $urls['url']; $thumb_url = $urls['thumb_url']; } else { warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN_UPLOAD')); } } else { $url = $urls[0]; $thumb_url = $urls[1]; } $caption = comcode_to_tempcode(post_param('caption', '')); $title = comcode_to_tempcode(post_param('title', '')); require_code('images'); $thumb = do_image_thumb(url_is_local($thumb_url) ? get_custom_base_url() . '/' . $thumb_url : $thumb_url, $caption, true); $url = url_is_local($url) ? get_custom_base_url() . '/' . $url : $url; $preview = do_template('IOTD', array('ID' => '', 'IMAGE_URL' => $url, 'SUBMITTER' => strval(get_member()), 'VIEW_URL' => $url, 'IMAGE' => $thumb, 'CAPTION' => $title)); return array($preview, NULL); }
/** * Convert a field value to something renderable. * * @param array The field details * @param mixed The raw value * @param integer Position in fieldset * @param ?array List of fields the output is being limited to (NULL: N/A) * @return mixed Rendered field (tempcode or string) */ function render_field_value($field, $ev, $i, $only_fields) { if (is_object($ev)) { return $ev; } if ($ev == '') { return ''; } $img_url = $ev; if (url_is_local($img_url)) { $img_url = get_custom_base_url() . '/' . $img_url; } if (get_option('is_on_gd') == '0' || !function_exists('imagetypes')) { $img_thumb_url = $img_url; } else { $new_name = url_to_filename($ev); require_code('images'); if (!is_saveable_image($new_name)) { $new_name .= '.png'; } $file_thumb = get_custom_file_base() . '/uploads/auto_thumbs/' . $new_name; if (!file_exists($file_thumb)) { convert_image($img_url, $file_thumb, -1, -1, intval(get_option('thumb_width')), false); } $img_thumb_url = get_custom_base_url() . '/uploads/auto_thumbs/' . rawurlencode($new_name); } if (!array_key_exists('c_name', $field)) { $field['c_name'] = 'other'; } $tpl_set = $field['c_name']; $GLOBALS['META_DATA'] += array('image' => $img_url); return do_template('CATALOGUE_' . $tpl_set . '_ENTRY_FIELD_PICTURE', array('I' => is_null($only_fields) ? '-1' : strval($i), 'CATALOGUE' => $field['c_name'], 'URL' => $img_url, 'THUMB_URL' => $img_thumb_url), NULL, false, 'CATALOGUE_DEFAULT_ENTRY_FIELD_PICTURE'); }
/** * Get a formatted-string filesize for the specified file. It is formatted as such: x Mb/Kb/Bytes (or unknown). It is assumed that the file exists. * * @param URLPATH The URL that the file size of is being worked out for. Should be local. * @return string The formatted-string file size */ function get_file_size($url) { if (substr($url, 0, strlen(get_base_url())) == get_base_url()) { $url = substr($url, strlen(get_base_url())); } if (!url_is_local($url)) { return do_lang('UNKNOWN'); } $_full = rawurldecode($url); $_full = get_file_base() . '/' . $_full; $file_size_bytes = filesize($_full); return clean_file_size($file_size_bytes); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { require_lang('iotds'); require_css('iotds'); $mode = array_key_exists('param', $map) ? $map['param'] : 'current'; $zone = array_key_exists('zone', $map) ? $map['zone'] : get_module_zone('iotds'); if (has_actual_page_access(NULL, 'cms_iotds', NULL, NULL) && has_submit_permission('mid', get_member(), get_ip_address(), 'cms_iotds')) { $submit_url = build_url(array('page' => 'cms_iotds', 'type' => 'ad', 'redirect' => SELF_REDIRECT), get_module_zone('cms_iotds')); } else { $submit_url = new ocp_tempcode(); } if ($mode == 'current') { $iotd = $GLOBALS['SITE_DB']->query_select('iotd', array('*'), array('is_current' => 1), 'ORDER BY id DESC', 1); } elseif (is_numeric($mode)) { $iotd = $GLOBALS['SITE_DB']->query_select('iotd', array('*'), array('id' => intval($mode)), '', 1); if (!array_key_exists(0, $iotd)) { return do_template('BLOCK_NO_ENTRIES', array('HIGH' => true, 'TITLE' => do_lang_tempcode('IOTD'), 'MESSAGE' => do_lang_tempcode('NO_ENTRIES'), 'ADD_NAME' => do_lang_tempcode('ADD_IOTD'), 'SUBMIT_URL' => $submit_url)); } } else { $cnt = $GLOBALS['SITE_DB']->query_value('iotd', 'COUNT(*)', array('used' => 1)); if ($cnt == 0) { return do_template('BLOCK_NO_ENTRIES', array('HIGH' => true, 'TITLE' => do_lang_tempcode('IOTD'), 'MESSAGE' => do_lang_tempcode('NO_ENTRIES'), 'ADD_NAME' => do_lang_tempcode('ADD_IOTD'), 'SUBMIT_URL' => $submit_url)); } $at = mt_rand(0, $cnt - 1); $iotd = $GLOBALS['SITE_DB']->query_select('iotd', array('*'), array('used' => 1), '', 1, $at); } if (!array_key_exists(0, $iotd)) { return do_template('BLOCK_NO_ENTRIES', array('_GUID' => '62baa388e068d4334f7a6c6093ead56a', 'HIGH' => true, 'TITLE' => do_lang_tempcode('IOTD'), 'MESSAGE' => do_lang_tempcode('NO_ENTRIES'), 'ADD_NAME' => do_lang_tempcode('ADD_IOTD'), 'SUBMIT_URL' => $submit_url)); } $myrow = $iotd[0]; $image_url = $myrow['url']; if (url_is_local($image_url)) { $image_url = get_custom_base_url() . '/' . $image_url; } $view_url = build_url(array('page' => 'iotds', 'wide' => 1, 'type' => 'view', 'id' => $myrow['id']), $zone); require_code('images'); $thumb_url = ensure_thumbnail($myrow['url'], $myrow['thumb_url'], 'iotds', 'iotd', $myrow['id']); $caption = get_translated_tempcode($myrow['i_title']); $image = do_image_thumb($thumb_url, do_lang('IOTD')); $archive_url = build_url(array('page' => 'iotds', 'type' => 'misc'), $zone); $tpl = do_template('IOTD', array('_GUID' => 'ca9c4b4941c12c15f7bdfe4cb57cd266', 'ID' => strval($myrow['id']), 'IMAGE_URL' => $image_url, 'SUBMITTER' => strval($myrow['submitter']), 'VIEW_URL' => $view_url, 'CAPTION' => $caption, 'IMAGE' => $image)); $map2 = array('_GUID' => 'd710da3675a1775867168ae37db02ad4', 'CURRENT' => $mode == 'current', 'FULL_URL' => $view_url, 'ID' => strval($myrow['id']), 'CONTENT' => $tpl, 'ARCHIVE_URL' => $archive_url, 'SUBMIT_URL' => $submit_url); if (get_option('is_on_comments') == '1' && get_forum_type() != 'none' && $myrow['allow_comments'] >= 1) { $map2['COMMENT_COUNT'] = '1'; } return do_template('BLOCK_MAIN_IOTD', $map2); }
/** * Function to process the file upload process */ function incoming_uploads_script() { $image_url_sub_for = get_param('image_url_sub_for', NULL); if ($image_url_sub_for !== NULL) { require_code('files'); if (!url_is_local($image_url_sub_for) || strpos($image_url_sub_for, '/incoming/') !== false) { $url_to = 'uploads/website_specific/' . md5(uniqid('', true)) . '.png'; } else { $url_to = dirname($image_url_sub_for) . '/' . md5(uniqid('', true)) . '.png'; } $write_to_file = fopen($url_to, 'wb'); http_download_file(either_param('imageurl'), NULL, true, false, 'ocPortal', NULL, NULL, NULL, NULL, NULL, $write_to_file); fclose($write_to_file); $GLOBALS['SITE_DB']->query_insert('image_url_sub_for', array('url_from' => $image_url_sub_for, 'url_to' => $url_to, 'member_id' => get_member(), 'expire' => time() + 60 * 60 * 24)); exit; } non_overrided__incoming_uploads_script(); }
/** * Standard modular run function for preview hooks. * * @return array A pair: The preview, the updated post Comcode */ function run() { require_code('uploads'); $urls = get_url('', 'file', 'safe_mode_temp', 0, OCP_UPLOAD_IMAGE, false); if ($urls[0] == '') { if (!is_null(post_param_integer('id', NULL))) { $rows = $GLOBALS['SITE_DB']->query_select('calendar_types', array('t_logo'), array('id' => post_param_integer('id')), '', 1); $urls = $rows[0]; $url = find_theme_image($urls['t_logo']); } elseif (!is_null(post_param('theme_img_code', NULL))) { $url = find_theme_image(post_param('theme_img_code')); } else { warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN_UPLOAD')); } } else { $url = $urls[0]; } require_code('images'); $preview = do_image_thumb(url_is_local($url) ? get_custom_base_url() . '/' . $url : $url, post_param('title'), true); return array($preview, NULL); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { require_lang('newsletter'); require_lang('javascript'); $newsletter_id = array_key_exists('param', $map) ? intval($map['param']) : db_get_first_id(); $_newsletter_title = $GLOBALS['SITE_DB']->query_value_null_ok('newsletters', 'title', array('id' => $newsletter_id)); if (is_null($_newsletter_title)) { return paragraph(do_lang_tempcode('MISSING_RESOURCE')); } $newsletter_title = get_translated_text($_newsletter_title); $address = post_param('address' . strval($newsletter_id), ''); if ($address != '') { require_code('newsletter'); require_code('type_validation'); if (!is_valid_email_address($address)) { $msg = do_template('INLINE_WIP_MESSAGE', array('MESSAGE' => do_lang_tempcode('INVALID_EMAIL_ADDRESS'))); return do_template('BLOCK_MAIN_NEWSLETTER_SIGNUP', array('URL' => get_self_url(), 'MSG' => $msg)); } if (!array_key_exists('path', $map)) { $map['path'] = 'uploads/website_specific/signup.txt'; } require_code('character_sets'); $password = basic_newsletter_join($address, 4, NULL, !file_exists(get_custom_file_base() . '/' . $map['path']), $newsletter_id, post_param('firstname' . strval($newsletter_id), ''), post_param('lastname' . strval($newsletter_id), '')); if ($password == '') { return do_template('INLINE_WIP_MESSAGE', array('MESSAGE' => do_lang_tempcode('NEWSLETTER_THIS_ALSO'))); } if ($password == do_lang('NA')) { $manage_url = build_url(array('page' => 'newsletter', 'email' => $address), get_module_zone('newsletter')); return do_template('INLINE_WIP_MESSAGE', array('MESSAGE' => do_lang_tempcode('ALREADY_EMAIL_ADDRESS', escape_html($manage_url->evaluate())))); } require_code('mail'); if (file_exists(get_custom_file_base() . '/' . $map['path'])) { $url = (url_is_local($map['path']) ? get_custom_base_url() . '/' : '') . $map['path']; mail_wrap(array_key_exists('subject', $map) ? $map['subject'] : do_lang('WELCOME'), convert_to_internal_encoding(http_download_file($url)), array($address), array_key_exists('to', $map) ? $map['to'] : '', '', '', 3, NULL, false, NULL, true); } return do_template('BLOCK_MAIN_NEWSLETTER_SIGNUP_DONE', array('_GUID' => '9953c83685df4970de8f23fcd5dd15bb', 'NEWSLETTER_TITLE' => $newsletter_title, 'NID' => strval($newsletter_id), 'PASSWORD' => $password)); } else { return do_template('BLOCK_MAIN_NEWSLETTER_SIGNUP', array('NEWSLETTER_TITLE' => $newsletter_title, 'NID' => strval($newsletter_id), 'URL' => get_self_url())); } }
/** * Standard modular run function for realtime-rain hooks. * * @param TIME Start of time range. * @param TIME End of time range. * @return array A list of template parameter sets for rendering a 'drop'. */ function run($from, $to) { $drops = array(); if (has_actual_page_access(get_member(), 'admin_banners')) { $rows = $GLOBALS['SITE_DB']->query('SELECT b.name,img_url,c_ip_address,c_member_id AS member_id,c_date_and_time AS timestamp FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'banner_clicks c LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'banners b ON b.name=c.c_banner_id WHERE c_date_and_time BETWEEN ' . strval($from) . ' AND ' . strval($to)); require_lang('banners'); foreach ($rows as $row) { $timestamp = $row['timestamp']; $member_id = $row['member_id']; $image = is_guest($member_id) ? rain_get_country_image($row['c_ip_address']) : $GLOBALS['FORUM_DRIVER']->get_member_avatar_url($member_id); require_code('images'); if (is_image($row['img_url'])) { $image = $row['img_url']; } if (url_is_local($image)) { $image = get_custom_base_url() . '/' . $image; } $drops[] = rain_get_special_icons($row['c_ip_address'], $timestamp) + array('TYPE' => 'banners', 'FROM_MEMBER_ID' => strval($member_id), 'TO_MEMBER_ID' => NULL, 'TITLE' => do_lang('BANNER_CLICKED'), 'IMAGE' => $image, 'TIMESTAMP' => strval($timestamp), 'RELATIVE_TIMESTAMP' => strval($timestamp - $from), 'TICKER_TEXT' => NULL, 'URL' => NULL, 'IS_POSITIVE' => true, 'IS_NEGATIVE' => false, 'FROM_ID' => 'member_' . strval($member_id), 'TO_ID' => NULL, 'GROUP_ID' => 'banner_' . $row['name']); } } return $drops; }
/** * Get the currently used download bandwidth. * * @return integer The currently used download bandwidth (forever) */ function get_download_bandwidth() { $value = intval(get_value_newer_than('download_bandwidth', time() - 60 * 60 * 24)); if ($value == 0) { $total = $GLOBALS['SITE_DB']->query_value_null_ok('download_downloads', 'COUNT(*)', array('validated' => 1)); if ($total > 200) { $value = $GLOBALS['SITE_DB']->query_value_null_ok('download_downloads', 'SUM(file_size*num_downloads)', array('validated' => 1)); } else { $value = 0; $rows = $GLOBALS['SITE_DB']->query_select('download_downloads', array('url', 'num_downloads'), array('validated' => 1)); foreach ($rows as $myrow) { if (url_is_local($myrow['url'])) { $file = get_custom_file_base() . '/' . rawurldecode($myrow['url']); if (file_exists($file)) { $value += filesize($file) * $myrow['num_downloads']; } } } set_value('download_bandwidth', strval($value)); } } return $value; }
/** * Standard modular run function for preview hooks. * * @return array A pair: The preview, the updated post Comcode */ function run() { require_code('uploads'); $cat = post_param('cat'); $urls = get_url('url', 'file', 'uploads/galleries' . (get_value('use_gallery_subdirs') == '1' ? '/' . $cat : ''), 0, OCP_UPLOAD_IMAGE, true, '', 'file2'); if ($urls[0] == '') { if (!is_null(post_param_integer('id', NULL))) { $rows = $GLOBALS['SITE_DB']->query_select('images', array('url', 'thumb_url'), array('id' => post_param_integer('id')), '', 1); $urls = $rows[0]; $url = $urls['url']; $thumb_url = $urls['thumb_url']; } else { warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN_UPLOAD')); } } else { $url = $urls[0]; $thumb_url = $urls[1]; } require_code('images'); $thumb = do_image_thumb(url_is_local($thumb_url) ? get_custom_base_url() . '/' . $thumb_url : $thumb_url, post_param('comments'), true); $preview = hyperlink(url_is_local($url) ? get_custom_base_url() . '/' . $url : $url, $thumb); return array($preview, NULL); }
/** * Delete the specified attachment * * @param AUTO_LINK The attachment ID to delete * @param object The database connection to use * @set ocp forum */ function _delete_attachment($id, $connection) { $connection->query_delete('attachment_refs', array('a_id' => $id)); // Get attachment details $_attachment_info = $connection->query_select('attachments', array('a_url', 'a_thumb_url'), array('id' => $id), '', 1); if (!array_key_exists(0, $_attachment_info)) { return; } // Already gone $attachment_info = $_attachment_info[0]; // Delete url and thumb_url if local if (url_is_local($attachment_info['a_url']) && substr($attachment_info['a_url'], 0, 19) == 'uploads/attachments') { $url = rawurldecode($attachment_info['a_url']); @unlink(get_custom_file_base() . '/' . $url); sync_file($url); if ($attachment_info['a_thumb_url'] != '' && strpos($attachment_info['a_thumb_url'], 'uploads/filedump/') === false) { $thumb_url = rawurldecode($attachment_info['a_thumb_url']); @unlink(get_custom_file_base() . '/' . $thumb_url); sync_file($thumb_url); } } // Delete attachment $connection->query_delete('attachments', array('id' => $id), '', 1); }
/** * Get the contents of an HTML page. * HTML isn't great... no dynamicness/reconfigurability at all. * We prefer comcode with [html]HTML goes here[/html] usage * * @param PATH The relative (to ocPortals base directory) path to the HTML page * @param ?PATH The file base to load from (NULL: standard) * @return string The page */ function load_html_page($string, $file_base = NULL) { if (is_null($file_base)) { $file_base = get_file_base(); } global $PAGE_STRING; if (is_null($PAGE_STRING)) { $PAGE_STRING = $string; } $html = file_get_contents($file_base . '/' . $string, FILE_TEXT); // Post-processing if (strpos($html, '<html') !== false) { $matches = array(); // Fix links to anything in same dir, by assuming either uploads/website_specific or an ocP page in same zone $link_attributes = array('src', 'href', 'action', 'data', 'codebase'); foreach ($link_attributes as $attribute) { $num_matches = preg_match_all('#<[^<>]* ' . $attribute . '="([^&"]+\\.[^&"\\.]+)"[^<>]*>#mis', $html, $matches); for ($i = 0; $i < $num_matches; $i++) { $old_link = $matches[1][$i]; $zone = '_SELF'; if ($old_link[0] == '/') { $old_link = substr($old_link, 1); $zone = ''; } $possible_zone = str_replace('/', '_', dirname($old_link)); if ($possible_zone == '.') { $possible_zone = ''; } if ($possible_zone != '' && $possible_zone != get_zone_name() && file_exists(get_file_base() . '/' . $possible_zone)) { $zone = $possible_zone; } if (substr($old_link, -4) == '.htm') { $_new_link = build_url(array('page' => basename(substr($old_link, 0, strlen($old_link) - 4))), $zone); $new_link = $_new_link->evaluate(); } elseif (substr($old_link, -5) == '.html') { $_new_link = build_url(array('page' => basename(substr($old_link, 0, strlen($old_link) - 5))), $zone); $new_link = $_new_link->evaluate(); } else { $new_link = $old_link; if (url_is_local($old_link)) { if (is_file(get_custom_file_base() . '/' . dirname($string) . '/' . $old_link)) { $new_link = get_custom_base_url() . '/' . dirname($string) . '/' . $old_link; } else { $new_link = get_custom_base_url() . '/uploads/website_specific/' . $old_link; } } } $html = str_replace(' ' . $attribute . '="' . $old_link . '"', ' ' . $attribute . '="' . $new_link . '"', $html); } } // Extract script, style, and link elements from head if (preg_match('#<\\s*head[^<>]*>(.*)<\\s*/\\s*head\\s*>#mis', $html, $matches) != 0) { global $EXTRA_HEAD; $head = $matches[1]; $head_patterns = array('#<\\s*script.*<\\s*/\\s*script\\s*>#misU', '#<\\s*link[^<>]*>#misU', '#<\\s*style.*<\\s*/\\s*style\\s*>#misU'); foreach ($head_patterns as $pattern) { $num_matches = preg_match_all($pattern, $head, $matches); for ($i = 0; $i < $num_matches; $i++) { $EXTRA_HEAD->attach($matches[0][$i]); } } } // Extra meta keywords and description, and title global $SEO_KEYWORDS, $SEO_DESCRIPTION, $SEO_TITLE; if (preg_match('#<\\s*meta\\s+name\\s*=\\s*"keywords"\\s+content="([^"]*)"#mi', $html, $matches) != 0) { $SEO_KEYWORDS = explode(',', @html_entity_decode(trim($matches[1]), ENT_QUOTES, get_charset())); } if (preg_match('#<\\s*meta\\s+name\\s*=\\s*"description"\\s+content="([^"]*)"#mi', $html, $matches) != 0) { $SEO_DESCRIPTION = @html_entity_decode(trim($matches[1]), ENT_QUOTES, get_charset()); } if (preg_match('#<\\s*title\\s*>([^<>]*)<\\s*/\\s*title\\s*>#mis', $html, $matches) != 0) { $SEO_TITLE = @html_entity_decode(trim($matches[1]), ENT_QUOTES, get_charset()); } // Extract body if (preg_match('#<\\s*body[^>]*>(.*)<\\s*/\\s*body\\s*>#mis', $html, $matches) != 0) { $html = $matches[1]; } else { $html = ''; } } return $html; }
/** * Get a map between smiley codes and templates representing the HTML-image-code for this smiley. The smilies present of course depend on the forum involved. * * @return array The map */ function find_emoticons() { global $EMOTICON_CACHE; if (!is_null($EMOTICON_CACHE)) { return $EMOTICON_CACHE; } $rows = $this->connection->query_select('smileys', array('*')); $EMOTICON_CACHE = array(); foreach ($rows as $myrow) { $src = $myrow['smfile']; $smfolder = $myrow['smfolder']; if (url_is_local($src)) { $src = $this->get_emo_dir() . $smfolder . '/' . $src; } $EMOTICON_CACHE[$myrow['smcode']] = array('EMOTICON_IMG_CODE_DIR', $src, $myrow['smcode']); } uksort($EMOTICON_CACHE, 'strlen_sort'); $EMOTICON_CACHE = array_reverse($EMOTICON_CACHE); return $EMOTICON_CACHE; }
/** * 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; } $file_contents = http_download_file($url, 1024 * 1024 * 20); list($_embed, $title) = do_code_box($extension, make_string_tempcode($file_contents)); if ($attachment['a_original_filename'] != '') { $title = escape_html($attachment['a_original_filename']); } $temp_tpl = do_template('COMCODE_CODE', array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true, 'STYLE' => '', 'TYPE' => $extension, 'CONTENT' => $_embed, 'TITLE' => $title)); break; case 'hyperlink': if ($tag == 'attachment') { $keep = symbol_tempcode('KEEP'); $_url = new ocp_tempcode(); $_url->attach(find_script('attachment') . '?id=' . urlencode($attachment['id']) . $keep->evaluate()); if (get_option('anti_leech') == '1') { $_url->attach('&for_session='); $_url->attach(symbol_tempcode('SESSION_HASHED')); } } else { $url = $attachment['a_url']; if (url_is_local($url)) { $url = get_custom_base_url() . '/' . $url; } $_url = make_string_tempcode($url); } $temp_tpl = hyperlink($_url, is_object($attachment['a_description']) ? $attachment['a_description']->evaluate() : $attachment['a_description'] != '' ? $attachment['a_description'] : $attachment['a_original_filename'], true); break; default: if (is_image($attachment['a_original_filename'])) { if ($type == 'inline' || $type == 'left_inline' || $type == 'right_inline') { $attachment['mini'] = '1'; } require_code('images'); ensure_thumbnail($attachment['a_url'], $attachment['a_thumb_url'], 'attachments', 'attachments', intval($attachment['id']), 'a_thumb_url'); $temp_tpl = do_template('ATTACHMENT_IMG' . (array_key_exists('mini', $attachment) && $attachment['mini'] == '1' ? '_MINI' : ''), map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true)); if ($type == 'left' || $type == 'left_inline') { $temp_tpl = do_template('ATTACHMENT_LEFT', array('_GUID' => 'aee2a6842d369c8dae212c3478a3a3e9', 'WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true, 'CONTENT' => $temp_tpl)); } if ($type == 'right' || $type == 'right_inline') { $temp_tpl = do_template('ATTACHMENT_RIGHT', array('_GUID' => '1a7209d67d91db740c86e7a331720195', 'WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true, 'CONTENT' => $temp_tpl)); } break; } elseif ($extension == 'swf') { $temp_tpl = do_template('ATTACHMENT_SWF', map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true)); break; } elseif (addon_installed('jwplayer') && ($mime_type == 'video/x-flv' || $mime_type == 'video/mp4' || $mime_type == 'video/webm')) { $temp_tpl = do_template('ATTACHMENT_FLV', map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true)); break; } elseif ($mime_type == 'video/quicktime') { $temp_tpl = do_template('ATTACHMENT_QT', map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true)); break; } elseif ($mime_type == 'audio/x-pn-realaudio') { $temp_tpl = do_template('ATTACHMENT_RM', map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true)); break; } elseif (substr($mime_type, 0, 5) == 'video' || substr($mime_type, 0, 5) == 'audio') { $temp_tpl = do_template('ATTACHMENT_MEDIA', map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true)); break; } // Continues on, as it's not a media type... // Continues on, as it's not a media type... case 'download': if (is_null($attachment['a_file_size'])) { $temp_tpl = do_template('ATTACHMENT_DOWNLOAD_REMOTE', map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true)); } else { $temp_tpl = do_template('ATTACHMENT_DOWNLOAD', map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true)); } break; } return $temp_tpl; }
/** * The UI to show a video. * * @param ?string Alternate category name to use (NULL: use standard one). This is useful if you are overriding this code to show images in virtual galleries. * @param ?tempcode Breadcrumbs (NULL: derive in this function). * @return tempcode The UI */ function show_video($category_name = NULL, $tree = NULL) { $id = get_param_integer('id'); if (get_param_integer('ajax', 0) == 1) { header('Content-type: text/xml'); } list($sort, $sort_backwards, $sql_suffix_images, $sql_suffix_videos) = $this->get_sort_order(); if (addon_installed('awards')) { require_code('awards'); $awards = find_awards_for('video', strval($id)); } else { $awards = array(); } // Pic up some info $rows = $GLOBALS['SITE_DB']->query_select('videos', array('*'), array('id' => $id), '', 1); if (!array_key_exists(0, $rows)) { return warn_screen(get_page_title('ERROR_OCCURRED'), do_lang_tempcode('MISSING_RESOURCE')); } $myrow = $rows[0]; $url = $myrow['url']; if (url_is_local($url)) { $url = get_custom_base_url() . '/' . $url; } $cat = $myrow['cat']; $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=galleries&filter=' . urlencode($cat); if (get_value('no_individual_gallery_view') === '1' && $GLOBALS['SITE_DB']->query_value('galleries', 'flow_mode_interface', array('name' => $cat)) == '1') { require_code('site2'); assign_refresh(build_url(array('page' => '_SELF', 'type' => 'misc', 'id' => $cat, 'probe_id' => $id, 'probe_type' => 'video'), '_SELF'), 0.0); } $true_category_name = get_translated_text($GLOBALS['SITE_DB']->query_value('galleries', 'fullname', array('name' => $cat))); if (is_null($category_name)) { $category_name = $true_category_name; } if (get_param_integer('slideshow', 0) == 1) { $title = get_page_title('VIEW_SLIDESHOW', true, array(escape_html($category_name))); global $EXTRA_HEAD; $EXTRA_HEAD->attach('<meta name="robots" content="noindex" />'); // XHTMLXHTML } else { $title = get_page_title(get_translated_text($myrow['title']) == '' ? 'VIEW_VIDEO' : '_VIEW_VIDEO', true, array(escape_html(get_translated_text($myrow['title']))), NULL, $awards); } $root = get_param('root', 'root'); seo_meta_load_for('video', strval($id)); $thumb_url = $myrow['thumb_url']; if (url_is_local($thumb_url)) { $thumb_url = get_custom_base_url() . '/' . $thumb_url; } if (!has_category_access(get_member(), 'galleries', $cat)) { access_denied('CATEGORY_ACCESS'); } // Views if (get_db_type() != 'xml') { $myrow['video_views']++; $GLOBALS['SITE_DB']->query_update('videos', array('video_views' => $myrow['video_views']), array('id' => $id), '', 1, NULL, false, true); } list($rating_details, $comment_details, $trackback_details) = embed_feedback_systems('videos', strval($id), $myrow['allow_rating'], $myrow['allow_comments'], $myrow['allow_trackbacks'], $myrow['validated'], $myrow['submitter'], build_url(array('page' => '_SELF', 'type' => 'video', 'id' => $id), '_SELF', NULL, false, false, true), get_translated_text($myrow['title']) == '' ? do_lang('VIEW_VIDEO_IN', $true_category_name) : get_translated_text($myrow['title']), get_value('comment_forum__videos')); // Validation if ($myrow['validated'] == 0) { if (!has_specific_permission(get_member(), 'jump_to_unvalidated')) { access_denied('SPECIFIC_PERMISSION', 'jump_to_unvalidated'); } $warning_details = do_template('WARNING_TABLE', array('_GUID' => 'b32faacba974e648a67e5e91ffd3d8e5', 'WARNING' => do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT'))); } else { $warning_details = new ocp_tempcode(); } // Comments $comments = get_translated_tempcode($myrow['comments']); if (has_actual_page_access(NULL, 'cms_galleries', NULL, NULL) && has_edit_permission('mid', get_member(), $myrow['submitter'], 'cms_galleries', array('galleries', $cat))) { $edit_url = build_url(array('page' => 'cms_galleries', 'type' => '_ev', 'id' => $id), get_module_zone('cms_galleries')); } else { $edit_url = new ocp_tempcode(); } $add_date = get_timezoned_date($myrow['add_date']); $edit_date = is_null($myrow['edit_date']) ? '' : get_timezoned_date($myrow['edit_date']); // Video HTML $video = show_gallery_media($url, $thumb_url, $myrow['video_width'], $myrow['video_height'], $myrow['video_length']); $extension = get_file_extension($url); require_code('mime_types'); $mime_type = get_mime_type($extension); list($n, $x, $nav) = $this->build_set_navigation(db_string_equal_to('cat', $cat), '', $category_name, $id, $root, 'video', get_param_integer('slideshow', 0), get_param_integer('wide_high', 0), get_param_integer('start', 0), get_param_integer('max', get_default_gallery_max()), $cat, $sort, $sort_backwards, $sql_suffix_images, $sql_suffix_videos, get_param('select', '*'), get_param('video_select', '*')); $member_id = get_member_id_from_gallery_name($cat, NULL, true); if (get_forum_type() == 'ocf') { require_code('ocf_members'); require_code('ocf_members2'); } $member_details = is_null($member_id) || get_forum_type() != 'ocf' ? new ocp_tempcode() : ocf_show_member_box($member_id); $video_details = show_video_details($myrow); if (is_null($tree)) { $tree = gallery_breadcrumbs($cat, $root, false, get_module_zone('galleries')); } breadcrumb_add_segment($tree, do_lang_tempcode('VIEW_VIDEO')); $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $myrow['add_date']), 'creator' => $GLOBALS['FORUM_DRIVER']->get_username($myrow['submitter']), 'publisher' => '', 'modified' => is_null($myrow['edit_date']) ? '' : date('Y-m-d', $myrow['edit_date']), 'type' => 'Video', 'title' => get_translated_text($myrow['title']), 'identifier' => '_SEARCH:galleries:video:' . strval($id), 'description' => get_translated_text($myrow['comments']), 'image' => $thumb_url, 'video' => $url, 'video:height' => strval($myrow['video_height']), 'video:width' => strval($myrow['video_width']), 'video:type' => $mime_type); return do_template('GALLERY_ENTRY_SCREEN', array('_GUID' => '91e231906ed899513ec2db8a2974dddf', 'MEDIA_TYPE' => 'video', 'E_TITLE' => get_translated_text($myrow['title']), 'CAT' => $cat, 'SLIDESHOW' => get_param_integer('slideshow', 0) == 1, 'TRUE_GALLERY_TITLE' => $true_category_name, 'GALLERY_TITLE' => $category_name, 'MEMBER_ID' => is_null($member_id) ? '' : strval($member_id), 'ID' => strval($id), 'TAGS' => get_loaded_tags('videos'), 'TITLE' => $title, 'SUBMITTER' => strval($myrow['submitter']), 'URL' => $url, 'VIDEO_DETAILS' => $video_details, 'MEMBER_DETAILS' => $member_details, 'X' => integer_format($x), 'N' => integer_format($n), 'VIEWS' => integer_format($myrow['video_views']), 'ADD_DATE_RAW' => strval($myrow['add_date']), 'EDIT_DATE_RAW' => is_null($myrow['edit_date']) ? '' : strval($myrow['edit_date']), 'ADD_DATE' => $add_date, 'EDIT_DATE' => $edit_date, 'RATING_DETAILS' => $rating_details, 'TRACKBACK_DETAILS' => $trackback_details, 'COMMENT_DETAILS' => $comment_details, 'EDIT_URL' => $edit_url, 'NAV' => $nav, 'COMMENTS' => $comments, 'VIDEO' => $video, 'WARNING_DETAILS' => $warning_details)); }
/** * Create a video thumbnail. * * @param URLPATH Video to get thumbail from (must be local) * @param ?PATH Where to save to (NULL: decide for ourselves) * @return URLPATH Thumbnail, only valid if expected_output_path was passed as NULL (blank: could not generate) */ function create_video_thumb($src_url, $expected_output_path = NULL) { // Audio ones should have automatic thumbnails require_code('mime_types'); $file_ext = get_file_extension($src_url); $input_mime_type = get_mime_type($file_ext); if (preg_match('#audio\\/#i', $input_mime_type) != 0) { $ret = find_theme_image('audio_thumb', true); if ($ret != '') { if (!is_null($expected_output_path)) { require_code('files'); $_expected_output_path = fopen($expected_output_path, 'wb'); http_download_file($ret, NULL, true, false, 'ocPortal', NULL, NULL, NULL, NULL, NULL, $_expected_output_path); fclose($_expected_output_path); } } return $ret; } // Try one of the hooks for video types $ve_hooks = find_all_hooks('systems', 'video_embed'); foreach (array_keys($ve_hooks) as $ve_hook) { require_code('hooks/systems/video_embed/' . $ve_hook); $ve_ob = object_factory('Hook_video_embed_' . $ve_hook); $thumbnail = $ve_ob->get_video_thumbnail($src_url); if (!is_null($thumbnail)) { return $thumbnail; } } // Ok, gonna try hard using what FFMPEG techniques we can... if (substr($src_url, 0, strlen(get_custom_base_url() . '/')) == get_custom_base_url() . '/') { $src_url = substr($src_url, strlen(get_custom_base_url() . '/')); } if (!url_is_local($src_url)) { return ''; } $src_file = get_custom_file_base() . '/' . rawurldecode($src_url); $src_file = preg_replace('#(\\\\|/)#', DIRECTORY_SEPARATOR, $src_file); if (class_exists('ffmpeg_movie')) { $filename = 'thumb_' . md5(uniqid('', true)) . '1.jpg'; if (is_null($expected_output_path)) { $expected_output_path = get_custom_file_base() . '/uploads/galleries/' . $filename; } if (file_exists($expected_output_path)) { return 'uploads/galleries/' . rawurlencode(basename($expected_output_path)); } $movie = @new ffmpeg_movie($src_file, false); if ($movie !== false) { if ($movie->getFrameCount() == 0) { return ''; } $frame = $movie->getFrame(min($movie->getFrameCount(), 25)); if (method_exists($frame, 'toGDImage')) { $gd_img = $frame->toGDImage(); @imagejpeg($gd_img, $expected_output_path); } else { $frame->save($expected_output_path); // New-style } if (file_exists($expected_output_path)) { require_code('images'); if (get_option('is_on_gd') == '1' && function_exists('imagecreatefromstring')) { convert_image($expected_output_path, $expected_output_path, -1, -1, intval(get_option('thumb_width')), true, NULL, true); } return 'uploads/galleries/' . rawurlencode(basename($expected_output_path)); } } } $ffmpeg_path = get_option('ffmpeg_path'); if ($ffmpeg_path != '' && strpos(@ini_get('disable_functions'), 'shell_exec') === false) { $filename = 'thumb_' . md5(uniqid(strval(post_param_integer('thumbnail_auto_position', 1)), true)) . '%d.jpg'; $dest_file = get_custom_file_base() . '/uploads/galleries/' . $filename; if (is_null($expected_output_path)) { $expected_output_path = str_replace('%d', '1', $dest_file); } if (file_exists($dest_file) && is_null(post_param_integer('thumbnail_auto_position', NULL))) { return 'uploads/galleries/' . rawurlencode(basename($expected_output_path)); } @unlink($dest_file); // So "if (@filesize($expected_output_path)) break;" will definitely fail if error $dest_file = preg_replace('#(\\\\|/)#', DIRECTORY_SEPARATOR, $dest_file); $at = display_seconds_period(post_param_integer('thumbnail_auto_position', 1)); if (strlen($at) == 5) { $at = '00:' . $at; } $shell_command = '"' . $ffmpeg_path . 'ffmpeg" -i ' . @escapeshellarg($src_file) . ' -an -ss ' . $at . ' -r 1 -vframes 1 -y ' . @escapeshellarg($dest_file); $shell_commands = array($shell_command, $shell_command . ' -map 0.0:0.0', $shell_command . ' -map 0.1:0.0'); foreach ($shell_commands as $shell_command) { shell_exec($shell_command); if (@filesize($expected_output_path)) { break; } } if (file_exists(str_replace('%d', '1', $dest_file))) { require_code('images'); if (get_option('is_on_gd') == '1' && function_exists('imagecreatefromstring')) { convert_image(str_replace('%d', '1', $dest_file), $expected_output_path, -1, -1, intval(get_option('thumb_width')), true, NULL, true); } else { copy(str_replace('%d', '1', $dest_file), $expected_output_path); fix_permissions($expected_output_path); sync_file($expected_output_path); } return 'uploads/galleries/' . rawurlencode(basename($expected_output_path)); } } return ''; }
/** * Edit a download. * * @param AUTO_LINK The ID of the download to edit * @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 * @param integer The ordered number of the gallery image to use as the download representative image * @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 SHORT_TEXT Meta keywords * @param LONG_TEXT Meta description */ function edit_download($id, $category_id, $name, $url, $description, $author, $comments, $out_mode_id, $default_pic, $validated, $allow_rating, $allow_comments, $allow_trackbacks, $notes, $original_filename, $file_size, $cost, $submitter_gets_points, $licence, $meta_keywords, $meta_description) { require_code('urls2'); suggest_new_idmoniker_for('downloads', 'view', strval($id), $name); if ($file_size == 0 || url_is_local($url)) { if (url_is_local($url)) { $file_size = filesize(get_custom_file_base() . '/' . rawurldecode($url)); } else { $file_size = @filesize($url) or $file_size = NULL; } } $myrows = $GLOBALS['SITE_DB']->query_select('download_downloads', array('name', 'description', 'comments'), array('id' => $id), '', 1); if (!array_key_exists(0, $myrows)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $myrow = $myrows[0]; require_code('seo2'); seo_meta_set_for_explicit('downloads_download', strval($id), $meta_keywords, $meta_description); require_code('files2'); delete_upload('uploads/downloads', 'download_downloads', 'url', 'id', $id, $url); $met = @ini_get('max_execution_time'); $data_mash = 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; } require_code('submit'); $just_validated = !content_validated('download', strval($id)) && $validated == 1; if ($just_validated) { send_content_validated_notification('download', strval($id)); } $map = array('download_data_mash' => $data_mash, 'download_licence' => $licence, 'original_filename' => $original_filename, 'download_submitter_gets_points' => $submitter_gets_points, 'download_cost' => $cost, 'edit_date' => time(), 'file_size' => $file_size, 'allow_rating' => $allow_rating, 'allow_comments' => $allow_comments, 'allow_trackbacks' => $allow_trackbacks, 'notes' => $notes, 'name' => lang_remap($myrow['name'], $name), 'description' => lang_remap_comcode($myrow['description'], $description), 'comments' => lang_remap_comcode($myrow['comments'], $comments), 'validated' => $validated, 'category_id' => $category_id, 'url' => $url, 'author' => $author, 'default_pic' => $default_pic, 'out_mode_id' => $out_mode_id); $GLOBALS['SITE_DB']->query_update('download_downloads', $map, array('id' => $id), '', 1); $self_url = build_url(array('page' => 'downloads', 'type' => 'entry', 'id' => $id), get_module_zone('downloads'), NULL, false, false, true); if ($just_validated) { require_lang('downloads'); require_code('notifications'); $subject = do_lang('DOWNLOAD_NOTIFICATION_MAIL_SUBJECT', get_site_name(), $name); $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('EDIT_DOWNLOAD', strval($id), get_translated_text($myrow['name'])); if (addon_installed('galleries')) { // Change its gallery require_code('galleries2'); $download_gallery_root = get_option('download_gallery_root'); if (is_null($download_gallery_root)) { $download_gallery_root = 'root'; } $test = $GLOBALS['SITE_DB']->query_value_null_ok('galleries', 'parent_id', array('name' => 'download_' . strval($id))); if (!is_null($test)) { edit_gallery('download_' . strval($id), 'download_' . strval($id), do_lang('GALLERY_FOR_DOWNLOAD', $name), '', '', '', $download_gallery_root); } } decache('main_recent_downloads'); decache('main_top_downloads'); decache('main_download_category'); decache('main_download_tease'); require_code('feedback'); update_spacer_post($allow_comments != 0, 'downloads', strval($id), $self_url, $name, get_value('comment_forum__downloads')); }
/** * Get enclosure details from a URL, as efficiently as possible. * * @param URLPATH The (possibly short) URL to get details for * @param URLPATH The full URL to get details for * @return array A pair: the length of the data, the mime type */ function get_enclosure_details($url, $enclosure_url) { $enclosure_length = '0'; if (url_is_local($url) && file_exists(get_custom_file_base() . '/' . rawurldecode($url))) { $enclosure_length = strval(@filesize(get_custom_file_base() . '/' . rawurldecode($url))); require_code('mime_types'); $enclosure_type = get_mime_type(get_file_extension($url)); } else { http_download_file($enclosure_url, 0, false); $enclosure_length = strval($GLOBALS['HTTP_DOWNLOAD_SIZE']); if (is_null($enclosure_length)) { $enclosure_length = strval(strlen(http_download_file($enclosure_url))); } $enclosure_type = $GLOBALS['HTTP_DOWNLOAD_MIME_TYPE']; } return array($enclosure_length, $enclosure_type); }
/** * Standard modular render function for profile tabs edit 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 tuple: The tab title, the tab body text (may be blank), the tab fields, extra Javascript (may be blank) the suggested tab order, hidden fields (optional) (NULL: if $leave_to_ajax_if_possible was set) */ function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false) { $title = do_lang_tempcode('AVATAR'); $order = 20; // Actualiser if (post_param_integer('submitting_avatar_tab', 0) == 1) { require_code('uploads'); if (has_specific_permission($member_id_viewing, 'own_avatars')) { if (!(is_swf_upload(true) && array_key_exists('avatar_file', $_FILES) || array_key_exists('avatar_file', $_FILES) && is_uploaded_file($_FILES['avatar_file']['tmp_name']))) { $urls = array(); $stock = post_param('avatar_alt_url', ''); if ($stock == '') { $stock = post_param('avatar_stock', NULL); if (!is_null($stock)) { $urls[0] = $stock == '' ? '' : find_theme_image($stock, false, true); } else { $urls[0] = ''; } // None } else { if (url_is_local($stock) && !$GLOBALS['FORUM_DRIVER']->is_super_admin($member_id_viewing)) { $old = $GLOBALS['FORUM_DB']->query_value('f_members', 'm_avatar_url', array('id' => $member_id_of)); if ($old != $stock) { access_denied('ASSOCIATE_EXISTING_FILE'); } } $urls[0] = $stock; // URL } } else { // We have chosen an upload. Note that we will not be looking at alt_url at this point, even though it is specified below for canonical reasons $urls = get_url('avatar_alt_url', 'avatar_file', file_exists(get_custom_file_base() . '/uploads/avatars') ? 'uploads/avatars' : 'uploads/ocf_avatars', 0, OCP_UPLOAD_IMAGE, false, '', '', false, true); if ((get_base_url() != get_forum_base_url() || array_key_exists('on_msn', $GLOBALS['SITE_INFO']) && $GLOBALS['SITE_INFO']['on_msn'] == '1') && $urls[0] != '' && url_is_local($urls[0])) { $urls[0] = get_custom_base_url() . '/' . $urls[0]; } } $avatar_url = $urls[0]; } else { $stock = post_param('avatar_stock'); $avatar_url = $stock == '' ? '' : find_theme_image($stock, false, true); } require_code('ocf_members_action'); require_code('ocf_members_action2'); ocf_member_choose_avatar($avatar_url, $member_id_of); attach_message(do_lang_tempcode('SUCCESS_SAVE'), 'inform'); } if ($leave_to_ajax_if_possible) { return NULL; } // UI fields $avatar_url = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_avatar_url'); require_javascript('javascript_multi'); $fields = new ocp_tempcode(); require_code('form_templates'); require_code('themes2'); $ids = get_all_image_ids_type('ocf_default_avatars', true); $found_it = false; foreach ($ids as $id) { $pos = strpos($avatar_url, '/' . $id); $selected = $pos !== false; if ($selected) { $found_it = true; } } $hidden = new ocp_tempcode(); if (has_specific_permission($member_id_viewing, 'own_avatars')) { $javascript = 'standardAlternateFields(\'avatar_file\',\'avatar_alt_url\',\'avatar_stock*\',true);'; $fields->attach(form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_UPLOAD'), 'avatar_file', false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images')))); handle_max_file_size($hidden, 'image'); $fields->attach(form_input_line(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('URL')), do_lang_tempcode('DESCRIPTION_ALTERNATE_URL'), 'avatar_alt_url', $found_it ? '' : $avatar_url, false)); $fields->attach(form_input_picture_choose_specific(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('STOCK')), do_lang_tempcode('DESCRIPTION_ALTERNATE_STOCK'), 'avatar_stock', $ids, $avatar_url, NULL, NULL, true)); } else { $javascript = ''; $fields->attach(form_input_picture_choose_specific(do_lang_tempcode('STOCK'), '', 'avatar_stock', $ids, $avatar_url, NULL, NULL, true)); } if ($avatar_url != '') { if (url_is_local($avatar_url)) { $avatar_url = get_complex_base_url($avatar_url) . '/' . $avatar_url; } $avatar = do_template('OCF_TOPIC_POST_AVATAR', array('_GUID' => '50a5902f3ab7e384d9cf99577b222cc8', 'AVATAR' => $avatar_url)); } else { $avatar = do_lang_tempcode('NONE_EM'); } $width = ocf_get_member_best_group_property($member_id_of, 'max_avatar_width'); $height = ocf_get_member_best_group_property($member_id_of, 'max_avatar_height'); $text = do_template('OCF_EDIT_AVATAR_TAB', array('_GUID' => 'dbdac6ca3bc752b54d2a24a4c6e69c7c', 'MEMBER_ID' => strval($member_id_of), 'USERNAME' => $GLOBALS['FORUM_DRIVER']->get_username($member_id_of), 'AVATAR' => $avatar, 'WIDTH' => integer_format($width), 'HEIGHT' => integer_format($height))); $hidden = new ocp_tempcode(); $hidden->attach(form_input_hidden('submitting_avatar_tab', '1')); return array($title, $fields, $text, $javascript, $order, $hidden); }
/** * Get a map between smiley codes and templates representing the HTML-image-code for this smiley. The smilies present of course depend on the forum involved. * * @return array The map */ function find_emoticons() { global $EMOTICON_CACHE; if (!is_null($EMOTICON_CACHE)) { return $EMOTICON_CACHE; } $rows = $this->connection->query_select('emoticons', array('*')); $EMOTICON_CACHE = array(); foreach ($rows as $myrow) { $src = $myrow['image']; if (url_is_local($src)) { $src = $this->get_emo_dir() . $src; } $EMOTICON_CACHE[$this->ipb_unescape($myrow['typed'])] = array('EMOTICON_IMG_CODE_DIR', $src, $myrow['typed']); } uksort($EMOTICON_CACHE, 'strlen_sort'); $EMOTICON_CACHE = array_reverse($EMOTICON_CACHE); return $EMOTICON_CACHE; }
/** * Script handler for downloading a gallery, as specified by GET parameters. */ function download_gallery_script() { if (function_exists('set_time_limit')) { @set_time_limit(0); } require_code('galleries'); // Closed site $site_closed = get_option('site_closed'); if ($site_closed == '1' && !has_specific_permission(get_member(), 'access_closed_site') && !$GLOBALS['IS_ACTUALLY_ADMIN']) { header('Content-Type: text/plain'); @exit(get_option('closed')); } require_lang('galleries'); require_code('zip'); $cat = get_param('cat'); if (!has_category_access(get_member(), 'galleries', $cat)) { access_denied('CATEGORY_ACCESS'); } check_specific_permission('may_download_gallery', array('galleries', $cat)); if (strpos($cat, chr(10)) !== false || strpos($cat, chr(13)) !== false) { log_hack_attack_and_exit('HEADER_SPLIT_HACK'); } $gallery_rows = $GLOBALS['SITE_DB']->query_select('galleries', array('*'), array('name' => $cat), '', 1); if (!array_key_exists(0, $gallery_rows)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $gallery_row = $gallery_rows[0]; // Send header header('Content-Type: application/octet-stream' . '; authoritative=true;'); if (strstr(ocp_srv('HTTP_USER_AGENT'), 'MSIE') !== false) { header('Content-Disposition: filename="gallery-' . $cat . '.zip"'); } else { header('Content-Disposition: attachment; filename="gallery-' . $cat . '.zip"'); } disable_php_memory_limit(); $rows = array_merge($GLOBALS['SITE_DB']->query_select('videos', array('url', 'add_date'), array('cat' => $cat, 'validated' => 1)), $GLOBALS['SITE_DB']->query_select('images', array('url', 'add_date'), array('cat' => $cat, 'validated' => 1))); $array = array(); foreach ($rows as $row) { $full_path = NULL; $data = NULL; if (url_is_local($row['url']) && file_exists(get_file_base() . '/' . urldecode($row['url']))) { $path = urldecode($row['url']); $full_path = get_file_base() . '/' . $path; if (file_exists($full_path)) { $time = filemtime($full_path); $name = $path; } else { continue; } } else { continue; // Actually we won't include them, if they are not local it implies it is not reasonable for them to lead to server load, and they may not even be native files $time = $row['add_date']; $name = basename(urldecode($row['url'])); $data = http_download_file($row['url']); } $array[] = array('name' => preg_replace('#^uploads/galleries/#', '', $name), 'time' => $time, 'data' => $data, 'full_path' => $full_path); } if ($gallery_row['rep_image'] != '') { if (url_is_local($gallery_row['rep_image']) && file_exists(get_file_base() . '/' . urldecode($gallery_row['rep_image']))) { $path = urldecode($gallery_row['rep_image']); $full_path = get_file_base() . '/' . $path; if (file_exists($full_path)) { $time = filemtime($full_path); $name = $path; $data = file_get_contents($full_path); } } else { $time = $gallery_row['add_date']; $name = basename(urldecode($gallery_row['rep_image'])); $data = http_download_file($gallery_row['rep_image']); } $array[] = array('name' => preg_replace('#^uploads/(galleries|grepimages)/#', '', $name), 'time' => $time, 'data' => $data); } @ini_set('zlib.output_compression', 'Off'); //$zip_file=create_zip_file($array); //header('Content-Length: '.strval(strlen($zip_file))); //echo $zip_file; create_zip_file($array, true); }
/** * The UI to view an IOTD. * * @return tempcode The UI */ function view() { $title = get_page_title('IOTD'); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('IOTD_ARCHIVE')))); $id = get_param_integer('id'); $rows = $GLOBALS['SITE_DB']->query_select('iotd', array('*'), array('id' => $id), '', 1); if (!array_key_exists(0, $rows)) { return warn_screen($title, do_lang_tempcode('MISSING_RESOURCE')); } $myrow = $rows[0]; list($rating_details, $comment_details, $trackback_details) = embed_feedback_systems(get_page_name(), strval($id), $myrow['allow_rating'], $myrow['allow_comments'], $myrow['allow_trackbacks'], is_null($myrow['date_and_time']) && $myrow['used'] == 0 ? 0 : 1, $myrow['submitter'], build_url(array('page' => '_SELF', 'type' => 'view', 'id' => $id), '_SELF', NULL, false, false, true), get_translated_text($myrow['i_title']), get_value('comment_forum__iotds')); $date_raw = strval($myrow['date_and_time']); $add_date_raw = strval($myrow['add_date']); $edit_date_raw = is_null($myrow['edit_date']) ? '' : strval($myrow['edit_date']); $date = get_timezoned_date($myrow['date_and_time']); $add_date = get_timezoned_date($myrow['add_date']); $edit_date = get_timezoned_date($myrow['edit_date']); // Views if (get_db_type() != 'xml') { $myrow['iotd_views']++; $GLOBALS['SITE_DB']->query_update('iotd', array('iotd_views' => $myrow['iotd_views']), array('id' => $id), '', 1, NULL, false, true); } if (has_actual_page_access(NULL, 'cms_iotds', NULL, NULL) && has_edit_permission('high', get_member(), $myrow['submitter'], 'cms_iotds')) { $edit_url = build_url(array('page' => 'cms_iotds', 'type' => '_ed', 'id' => $id), get_module_zone('cms_iotds')); } else { $edit_url = new ocp_tempcode(); } $url = $myrow['url']; if (url_is_local($url)) { $url = get_custom_base_url() . '/' . $url; } $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $myrow['add_date']), 'creator' => $GLOBALS['FORUM_DRIVER']->get_username($myrow['submitter']), 'publisher' => '', 'modified' => is_null($myrow['edit_date']) ? '' : date('Y-m-d', $myrow['edit_date']), 'type' => 'Poll', 'title' => get_translated_text($myrow['i_title']), 'identifier' => '_SEARCH:iotds:view:' . strval($id), 'description' => '', 'image' => $url); return do_template('IOTD_VIEW_SCREEN', array('_GUID' => 'f508d483459b88fab44cd8b9f4db780b', 'TITLE' => $title, 'SUBMITTER' => strval($myrow['submitter']), 'I_TITLE' => get_translated_tempcode($myrow['i_title']), 'CAPTION' => get_translated_tempcode($myrow['caption']), 'DATE_RAW' => $date_raw, 'ADD_DATE_RAW' => $add_date_raw, 'EDIT_DATE_RAW' => $edit_date_raw, 'DATE' => $date, 'ADD_DATE' => $add_date, 'EDIT_DATE' => $edit_date, 'VIEWS' => integer_format($myrow['iotd_views']), 'TRACKBACK_DETAILS' => $trackback_details, 'RATING_DETAILS' => $rating_details, 'COMMENT_DETAILS' => $comment_details, 'EDIT_URL' => $edit_url, 'URL' => $url)); }
/** * Take some image/thumbnail info, and if needed make and caches a thumbnail, and return a thumb url whatever the situation. * * @param URLPATH The full URL to the image which will-be/is thumbnailed * @param URLPATH The URL to the thumbnail (blank: no thumbnail yet) * @param ID_TEXT The directory, relative to the ocPortal uploads directory, where the thumbnails are stored. MINUS "_thumbs" * @param ID_TEXT The name of the table that is storing what we are doing the thumbnail for * @param AUTO_LINK The ID of the table record that is storing what we are doing the thumbnail for * @param ID_TEXT The name of the table field where thumbnails are saved * @param ?integer The thumbnail width to use (NULL: default) * @return URLPATH The URL to the thumbnail */ function ensure_thumbnail($full_url, $thumb_url, $thumb_dir, $table, $id, $thumb_field_name = 'thumb_url', $thumb_width = NULL) { if (is_null($thumb_width)) { $thumb_width = intval(get_option('thumb_width')); } if (get_option('is_on_gd') == '0' || !function_exists('imagetypes') || $full_url == '') { if (url_is_local($thumb_url) && $thumb_url != '') { return get_custom_base_url() . '/' . $thumb_url; } return $thumb_url; } if ($thumb_url != '') { if (url_is_local($thumb_url)) { $thumb_path = get_custom_file_base() . '/' . rawurldecode($thumb_url); if (!file_exists($thumb_path)) { $from = str_replace(' ', '%20', $full_url); if (url_is_local($from)) { $from = get_custom_base_url() . '/' . $from; } if (is_video($from)) { require_code('galleries2'); create_video_thumb($full_url, $thumb_path); } else { convert_image($from, $thumb_path, intval($thumb_width), -1, -1, false); } } return get_custom_base_url() . '/' . $thumb_url; } return $thumb_url; } $url_parts = explode('/', $full_url); $i = 0; $_file = $url_parts[count($url_parts) - 1]; $dot_pos = strrpos($_file, '.'); $ext = substr($_file, $dot_pos + 1); if (!is_saveable_image($_file)) { $ext = 'png'; } $_file = preg_replace('#[^\\w]#', 'x', substr($_file, 0, $dot_pos)); $thumb_path = ''; do { $file = rawurldecode($_file) . ($i == 0 ? '' : strval($i)); $thumb_path = get_custom_file_base() . '/uploads/' . $thumb_dir . '_thumbs/' . $file . '.' . $ext; $i++; } while (file_exists($thumb_path)); $thumb_url = 'uploads/' . $thumb_dir . '_thumbs/' . rawurlencode($file) . '.' . $ext; if (substr($table, 0, 2) == 'f_' && get_forum_type() == 'ocf') { $GLOBALS['FORUM_DB']->query_update($table, array($thumb_field_name => $thumb_url), array('id' => $id), '', 1); } else { $GLOBALS['SITE_DB']->query_update($table, array($thumb_field_name => $thumb_url), array('id' => $id), '', 1); } $from = str_replace(' ', '%20', $full_url); if (url_is_local($from)) { $from = get_custom_base_url() . '/' . $from; } if (!file_exists($thumb_path)) { if (is_video($from)) { require_code('galleries2'); create_video_thumb($full_url, $thumb_path); } else { convert_image($from, $thumb_path, intval($thumb_width), -1, -1, false); } } return get_custom_base_url() . '/' . $thumb_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) { $title = do_lang_tempcode('PROFILE'); $order = 10; $photo_url = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_photo_url'); if ($photo_url != '' && addon_installed('ocf_member_photos') && has_specific_permission($member_id_viewing, 'view_member_photos')) { require_code('images'); $photo_thumb_url = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_photo_thumb_url'); $photo_thumb_url = ensure_thumbnail($photo_url, $photo_thumb_url, strpos($photo_url, 'uploads/photos') !== false ? 'photos' : 'ocf_photos', 'f_members', $member_id_of, 'm_photo_thumb_url'); if (url_is_local($photo_url)) { $photo_url = get_complex_base_url($photo_url) . '/' . $photo_url; } if (url_is_local($photo_thumb_url)) { $photo_thumb_url = get_complex_base_url($photo_thumb_url) . '/' . $photo_thumb_url; } } else { $photo_url = ''; $photo_thumb_url = ''; } $avatar_url = $GLOBALS['FORUM_DRIVER']->get_member_avatar_url($member_id_of); $username = $GLOBALS['FORUM_DRIVER']->get_username($member_id_of); // Things staff can do with this user $modules = array(); if (has_specific_permission($member_id_viewing, 'warn_members') && has_actual_page_access($member_id_viewing, 'warnings') && addon_installed('ocf_warnings')) { $redir_url = get_self_url(true); $modules[] = array('usage', do_lang_tempcode('WARN_MEMBER'), build_url(array('page' => 'warnings', 'type' => 'ad', 'id' => $member_id_of, 'redirect' => $redir_url), get_module_zone('warnings'))); $modules[] = array('usage', do_lang_tempcode('PUNITIVE_HISTORY'), build_url(array('page' => 'warnings', 'type' => 'history', 'id' => $member_id_of), get_module_zone('warnings'))); } if (has_specific_permission($member_id_viewing, 'view_content_history') && has_actual_page_access($member_id_viewing, 'admin_ocf_history')) { $modules[] = !addon_installed('ocf_forum') ? NULL : array('usage', do_lang_tempcode('POST_HISTORY'), build_url(array('page' => 'admin_ocf_history', 'member_id' => $member_id_of), 'adminzone')); } if (has_actual_page_access($member_id_viewing, 'admin_lookup')) { require_lang('submitban'); $modules[] = array('usage', do_lang_tempcode('INVESTIGATE_USER'), build_url(array('page' => 'admin_lookup', 'param' => $member_id_of), 'adminzone')); } if (has_actual_page_access($member_id_viewing, 'admin_security')) { require_lang('security'); $modules[] = array('usage', do_lang_tempcode('SECURITY_LOGGING'), build_url(array('page' => 'admin_security', 'member_id' => $member_id_of), 'adminzone')); } if (addon_installed('actionlog')) { if (has_actual_page_access($member_id_viewing, 'admin_actionlog')) { require_lang('submitban'); $modules[] = array('usage', do_lang_tempcode('VIEW_ACTION_LOGS'), build_url(array('page' => 'admin_actionlog', 'type' => 'list', 'id' => $member_id_of), 'adminzone')); } } if (has_actual_page_access($member_id_viewing, 'search') && addon_installed('ocf_forum') && addon_installed('search')) { $modules[] = array('content', do_lang_tempcode('SEARCH_POSTS'), build_url(array('page' => 'search', 'type' => 'results', 'id' => 'ocf_posts', 'author' => $username, 'sort' => 'add_date', 'direction' => 'DESC', 'content' => ''), get_module_zone('search')), 'search'); } if (has_actual_page_access($member_id_viewing, 'search') && addon_installed('search')) { $modules[] = array('content', do_lang_tempcode('SEARCH'), build_url(array('page' => 'search', 'type' => 'misc', 'author' => $username), get_module_zone('search')), 'search'); } if (addon_installed('authors')) { $author = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT author FROM ' . get_table_prefix() . 'authors WHERE (forum_handle=' . strval($member_id_viewing) . ') OR (forum_handle IS NULL AND ' . db_string_equal_to('author', $username) . ')'); if (has_actual_page_access($member_id_viewing, 'authors') && !is_null($author)) { $modules[] = array('content', do_lang_tempcode('AUTHOR'), build_url(array('page' => 'authors', 'type' => 'misc', 'id' => $author), get_module_zone('authors')), 'me'); } } require_code('ocf_members2'); if (!is_guest() && ocf_may_whisper($member_id_of) && has_actual_page_access($member_id_viewing, 'topics') && ocf_may_make_personal_topic() && $member_id_viewing != $member_id_of) { $modules[] = !addon_installed('ocf_forum') ? NULL : array('contact', do_lang_tempcode('ADD_PERSONAL_TOPIC'), build_url(array('page' => 'topics', 'type' => 'new_pt', 'id' => $member_id_of), get_module_zone('topics')), 'reply'); } $extra_sections = array(); $info_details = array(); $hooks = find_all_hooks('modules', 'members'); foreach (array_keys($hooks) as $hook) { require_code('hooks/modules/members/' . filter_naughty_harsh($hook)); $object = object_factory('Hook_members_' . filter_naughty_harsh($hook), true); if (is_null($object)) { continue; } if (method_exists($object, 'run')) { $hook_result = $object->run($member_id_of); $modules = array_merge($modules, $hook_result); } if (method_exists($object, 'get_info_details')) { $hook_result = $object->get_info_details($member_id_of); $info_details = array_merge($info_details, $hook_result); } if (method_exists($object, 'get_sections')) { $hook_result = $object->get_sections($member_id_of); $extra_sections = array_merge($extra_sections, $hook_result); } } if (addon_installed('ocf_contactmember')) { if (($GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_allow_emails') == 1 || get_option('allow_email_disable') == '0') && $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_email_address') != '' && !is_guest($member_id_of) && has_actual_page_access($member_id_viewing, 'contactmember') && $member_id_viewing != $member_id_of) { $redirect = get_self_url(true); $modules[] = array('contact', do_lang_tempcode('_EMAIL_MEMBER'), build_url(array('page' => 'contactmember', 'redirect' => $redirect, 'id' => $member_id_of), get_module_zone('contactmember')), 'reply'); } } require_lang('menus'); $sections = array('contact' => do_lang_tempcode('CONTACT'), 'profile' => do_lang_tempcode('EDIT_PROFILE'), 'views' => do_lang_tempcode('ACCOUNT'), 'usage' => do_lang_tempcode('USAGE'), 'content' => do_lang_tempcode('CONTENT')); $actions = array(); global $M_SORT_KEY; $M_SORT_KEY = mixed(); $M_SORT_KEY = 1; @uasort($modules, 'multi_sort'); /* @ is to stop PHP bug warning about altered array contents when Tempcode copies are evaluated internally */ foreach ($sections as $section_code => $section_title) { $links = new ocp_tempcode(); foreach ($modules as $module) { if (count($module) == 3) { list($_section_code, $lang, $url) = $module; $rel = NULL; } else { list($_section_code, $lang, $url, $rel) = $module; } if ($section_code == $_section_code) { $links->attach(do_template('OCF_MEMBER_ACTION', array('_GUID' => '67b2a640a368c6f53f1b1fa10f922fd0', 'ID' => strval($member_id_of), 'URL' => $url, 'LANG' => $lang, 'REL' => $rel))); } } $actions[$section_code] = $links; } // Custom fields $_custom_fields = ocf_get_all_custom_fields_match_member($member_id_of, $member_id_viewing != $member_id_of && !has_specific_permission($member_id_viewing, 'view_any_profile_field') ? 1 : NULL, $member_id_viewing == $member_id_of && !has_specific_permission($member_id_viewing, 'view_any_profile_field') ? 1 : NULL); $custom_fields = array(); require_code('encryption'); $value = mixed(); foreach ($_custom_fields as $name => $_value) { $value = $_value['RAW']; $rendered_value = $_value['RENDERED']; $encrypted_value = ''; if (is_data_encrypted($value)) { $encrypted_value = remove_magic_encryption_marker($value); } elseif (is_integer($value)) { $value = strval($value); } elseif (is_float($value)) { $value = float_to_raw_string($value); } if (!is_object($value) && $value != '' || is_object($value) && !$value->is_empty()) { $custom_fields[] = array('NAME' => $name, 'RAW_VALUE' => $value, 'VALUE' => $rendered_value, 'ENCRYPTED_VALUE' => $encrypted_value); if ($name == do_lang('KEYWORDS')) { $GLOBALS['SEO_KEYWORDS'] = is_object($value) ? $value->evaluate() : $value; } if ($name == do_lang('DESCRIPTION')) { $GLOBALS['SEO_DESCRIPTION'] = is_object($value) ? $value->evaluate() : $value; } } } // Birthday $dob = ''; if ($GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_reveal_age') == 1) { $day = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_dob_day'); $month = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_dob_month'); $year = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_dob_year'); if (!is_null($day)) { if (@strftime('%Y', @mktime(0, 0, 0, 1, 1, 1963)) != '1963') { $dob = strval($year) . '-' . str_pad(strval($month), 2, '0', STR_PAD_LEFT) . '-' . str_pad(strval($day), 2, '0', STR_PAD_LEFT); } else { $dob = get_timezoned_date(mktime(12, 0, 0, $month, $day, $year), false, true, true); } } } // Find forum with most posts $forums = $GLOBALS['FORUM_DB']->query('SELECT id,f_name FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_forums WHERE f_cache_num_posts>0'); $best_yet_forum = 0; // Initialise to integer type $best_yet_forum = NULL; $most_active_forum = NULL; $_best_yet_forum = $GLOBALS['FORUM_DB']->query_select('f_posts', array('COUNT(*) as cnt', 'p_cache_forum_id'), array('p_poster' => $member_id_of), 'GROUP BY p_cache_forum_id'); $_best_yet_forum = collapse_2d_complexity('p_cache_forum_id', 'cnt', $_best_yet_forum); foreach ($forums as $forum) { if (array_key_exists($forum['id'], $_best_yet_forum) && (is_null($best_yet_forum) || $_best_yet_forum[$forum['id']] > $best_yet_forum)) { $most_active_forum = has_category_access($member_id_viewing, 'forums', strval($forum['id'])) ? protect_from_escaping(escape_html($forum['f_name'])) : do_lang_tempcode('PROTECTED_FORUM'); $best_yet_forum = $_best_yet_forum[$forum['id']]; } } $post_count = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_cache_num_posts'); $best_post_fraction = $post_count == 0 ? do_lang_tempcode('NA_EM') : make_string_tempcode(integer_format(100 * $best_yet_forum / $post_count)); $most_active_forum = is_null($best_yet_forum) ? new ocp_tempcode() : do_lang_tempcode('_MOST_ACTIVE_FORUM', $most_active_forum, make_string_tempcode(integer_format($best_yet_forum)), array($best_post_fraction)); $time_for_them_raw = tz_time(time(), get_users_timezone($member_id_of)); $time_for_them = get_timezoned_time(time(), true, $member_id_of); $banned = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_is_perm_banned') == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO'); $last_submit_time = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_last_submit_time'); $submit_days_ago = intval(floor(floatval(time() - $last_submit_time) / 60.0 / 60.0 / 24.0)); require_code('ocf_groups'); $primary_group_id = ocf_get_member_primary_group($member_id_of); $primary_group = ocf_get_group_link($primary_group_id); $signature = get_translated_tempcode($GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_signature'), $GLOBALS['FORUM_DB']); $last_visit_time = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_last_visit_time'); if (member_is_online($member_id_of)) { $online_now = do_lang_tempcode('YES'); $_online_now = true; } else { $_online_now = false; $minutes_ago = intval(floor(floatval(time() - $last_visit_time) / 60.0)); $hours_ago = intval(floor(floatval(time() - $last_visit_time) / 60.0 / 60.0)); $days_ago = intval(floor(floatval(time() - $last_visit_time) / 60.0 / 60.0 / 24.0)); $months_ago = intval(floor(floatval(time() - $last_visit_time) / 60.0 / 60.0 / 24.0 / 31.0)); if ($minutes_ago < 180) { $online_now = do_lang_tempcode('_ONLINE_NOW_NO_MINUTES', integer_format($minutes_ago)); } elseif ($hours_ago < 72) { $online_now = do_lang_tempcode('_ONLINE_NOW_NO_HOURS', integer_format($hours_ago)); } elseif ($days_ago < 93) { $online_now = do_lang_tempcode('_ONLINE_NOW_NO_DAYS', integer_format($days_ago)); } else { $online_now = do_lang_tempcode('_ONLINE_NOW_NO_MONTHS', integer_format($months_ago)); } } $join_time = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_join_time'); $days_joined = intval(round((time() - $join_time) / 60 / 60 / 24)); $total_posts = $GLOBALS['FORUM_DB']->query_value('f_posts', 'COUNT(*)'); $join_date = $join_time == 0 ? '' : get_timezoned_date($join_time, false); $count_posts = do_lang_tempcode('_COUNT_POSTS', integer_format($post_count), float_format(floatval($post_count) / floatval($days_joined == 0 ? 1 : $days_joined)), array(float_format(floatval(100 * $post_count) / floatval($total_posts == 0 ? 1 : $total_posts)))); $a = $avatar_url == '' ? 0 : ocf_get_member_best_group_property($member_id_of, 'max_avatar_width'); $b = $photo_thumb_url == '' ? 0 : intval(get_option('thumb_width')); $right_margin = max($a, $b) == 0 ? 'auto' : strval(max($a, $b) + 6) . 'px'; breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MEMBERS')))); if (has_specific_permission($member_id_viewing, 'see_ip')) { $ip_address = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_ip_address'); } else { $ip_address = ''; } $secondary_groups = ocf_get_members_groups($member_id_of, true); unset($secondary_groups[$primary_group_id]); if (count($secondary_groups) > 0) { $_secondary_groups = array(); $all_groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(true, false, false, array_keys($secondary_groups), $member_id_of); foreach (array_keys($secondary_groups) as $key) { $_secondary_groups[$key] = $all_groups[$key]; } $secondary_groups = $_secondary_groups; } if (addon_installed('points')) { require_code('points'); $count_points = integer_format(total_points($member_id_of)); } else { $count_points = ''; } $user_agent = NULL; $operating_system = NULL; if (has_specific_permission($member_id_viewing, 'show_user_browsing') && addon_installed('stats')) { $last_stats = $GLOBALS['SITE_DB']->query_select('stats', array('browser', 'operating_system'), array('the_user' => $member_id_of), 'ORDER BY date_and_time DESC', 1); if (array_key_exists(0, $last_stats)) { $user_agent = $last_stats[0]['browser']; $operating_system = $last_stats[0]['operating_system']; } } /*if ((get_option('allow_member_integration')!='off') && (get_option('allow_member_integration')!='hidden')) { $remote=$GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of,'m_password_compat_scheme')=='remote'; } else */ $remote = NULL; $_on_probation = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_on_probation_until'); if (is_null($_on_probation) || $_on_probation <= time()) { $on_probation = NULL; } else { $on_probation = strval($_on_probation); } $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $join_time), 'creator' => $username, 'publisher' => '', 'modified' => '', 'type' => 'Member', 'title' => '', 'identifier' => '_SEARCH:members:view:' . strval($member_id_of), 'description' => '', 'image' => $avatar_url == '' && has_specific_permission($member_id_viewing, 'view_member_photos') ? $photo_url : $avatar_url); // Look up member's clubs $clubs = array(); if (addon_installed('ocf_clubs')) { $club_ids = $GLOBALS['FORUM_DRIVER']->get_members_groups($member_id_of, true); $club_rows = list_to_map('id', $GLOBALS['FORUM_DB']->query_select('f_groups', array('*'), array('g_is_private_club' => 1), '', 200)); if (count($club_rows) == 200) { $club_rows = NULL; } foreach ($club_ids as $club_id) { if (is_null($club_rows)) { $club_rows = list_to_map('id', $GLOBALS['FORUM_DB']->query_select('f_groups', array('*'), array('g_is_private_club' => 1, 'id' => $club_id), '', 200)); if (!array_key_exists($club_id, $club_rows)) { continue; } $club_row = $club_rows[$club_id]; $club_rows = NULL; } else { if (!array_key_exists($club_id, $club_rows)) { continue; } $club_row = $club_rows[$club_id]; } $club_name = get_translated_text($club_row['g_name'], $GLOBALS['FORUM_DB']); $club_forum = $GLOBALS['FORUM_DB']->query_value_null_ok('f_forums f LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON t.id=f.f_description', 'f.id', array('text_original' => do_lang('FORUM_FOR_CLUB', $club_name))); $clubs[] = array('CLUB_NAME' => $club_name, 'CLUB_ID' => strval($club_row['id']), 'CLUB_FORUM' => is_null($club_forum) ? '' : strval($club_forum)); } } $content = do_template('OCF_MEMBER_PROFILE_ABOUT', array('_GUID' => 'fodfjdsfjsdljfdls', 'CLUBS' => $clubs, 'REMOTE' => $remote, 'RIGHT_MARGIN' => $right_margin, 'AVATAR_WIDTH' => strval($a) . 'px', 'PHOTO_WIDTH' => strval($b) . 'px', 'MOST_ACTIVE_FORUM' => $most_active_forum, 'TIME_FOR_THEM' => $time_for_them, 'TIME_FOR_THEM_RAW' => strval($time_for_them_raw), 'SUBMIT_DAYS_AGO' => integer_format($submit_days_ago), 'SUBMIT_TIME_RAW' => strval($last_submit_time), 'LAST_VISIT_TIME_RAW' => strval($last_visit_time), 'ONLINE_NOW' => $online_now, '_ONLINE_NOW' => $_online_now, 'BANNED' => $banned, 'USER_AGENT' => $user_agent, 'OPERATING_SYSTEM' => $operating_system, 'DOB' => $dob, 'IP_ADDRESS' => $ip_address, 'COUNT_POSTS' => $count_posts, 'COUNT_POINTS' => $count_points, 'PRIMARY_GROUP' => $primary_group, 'PRIMARY_GROUP_ID' => strval($primary_group_id), 'PHOTO_URL' => $photo_url, 'PHOTO_THUMB_URL' => $photo_thumb_url, 'EMAIL_ADDRESS' => $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_email_address'), 'AVATAR_URL' => $avatar_url, 'SIGNATURE' => $signature, 'JOIN_DATE' => $join_date, 'JOIN_DATE_RAW' => strval($join_time), 'CUSTOM_FIELDS' => $custom_fields, 'ACTIONS_contact' => $actions['contact'], 'ACTIONS_profile' => $actions['profile'], 'ACTIONS_views' => $actions['views'], 'ACTIONS_usage' => $actions['usage'], 'ACTIONS_content' => $actions['content'], 'USERNAME' => $username, 'MEMBER_ID' => strval($member_id_of), 'SECONDARY_GROUPS' => $secondary_groups, 'VIEW_PROFILES' => $member_id_viewing == $member_id_of || has_specific_permission($member_id_viewing, 'view_profiles'), 'ON_PROBATION' => $on_probation, 'EXTRA_INFO_DETAILS' => $info_details, 'EXTRA_SECTIONS' => $extra_sections)); return array($title, $content, $order); }
/** * The UI to view a download. * * @return tempcode The UI */ function dloadinfo_screen() { $id = get_param_integer('id'); $root = get_param_integer('root', db_get_first_id(), true); // Basic Init $rows = $GLOBALS['SITE_DB']->query_select('download_downloads', array('*'), array('id' => $id), '', 1); if (!array_key_exists(0, $rows)) { return warn_screen(get_page_title('SECTION_DOWNLOADS'), do_lang_tempcode('MISSING_RESOURCE')); } $myrow = $rows[0]; $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=downloads&filter=' . strval($myrow['category_id']); if (!has_category_access(get_member(), 'downloads', strval($myrow['category_id']))) { access_denied('CATEGORY_ACCESS'); } $name = get_translated_text($myrow['name']); list($rating_details, $comment_details, $trackback_details) = embed_feedback_systems(get_page_name(), strval($id), $myrow['allow_rating'], $myrow['allow_comments'], $myrow['allow_trackbacks'], $myrow['validated'], $myrow['submitter'], build_url(array('page' => '_SELF', 'type' => 'entry', 'id' => $id), '_SELF', NULL, false, false, true), $name, get_value('comment_forum__downloads')); // Views if (get_db_type() != 'xml') { $myrow['download_views']++; $GLOBALS['SITE_DB']->query_update('download_downloads', array('download_views' => $myrow['download_views']), array('id' => $id), '', 1, NULL, false, true); } // Tree $tree = download_breadcrumbs($myrow['category_id'], $root, false, get_zone_name()); $title_to_use = do_lang_tempcode('DOWNLOAD_TITLE', escape_html($name)); $title_to_use_2 = do_lang('DOWNLOAD_TITLE', $name); if (addon_installed('awards')) { require_code('awards'); $awards = find_awards_for('download', strval($id)); } else { $awards = array(); } $title = get_page_title($title_to_use, false, NULL, NULL, $awards); seo_meta_load_for('downloads_download', strval($id), $title_to_use_2); $warning_details = new ocp_tempcode(); // Validation if ($myrow['validated'] == 0) { if (!has_specific_permission(get_member(), 'jump_to_unvalidated')) { access_denied('SPECIFIC_PERMISSION', 'jump_to_unvalidated'); } $warning_details->attach(do_template('WARNING_TABLE', array('_GUID' => '5b1781b8fbb1ef9b8f47693afcff02b9', 'WARNING' => do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT')))); } // Cost warning if ($myrow['download_cost'] != 0 && addon_installed('points')) { require_lang('points'); $warning_details->attach(do_template('WARNING_TABLE', array('_GUID' => '05fc448bf79b373385723c5af5ec93af', 'WARNING' => do_lang_tempcode('WILL_COST', integer_format($myrow['download_cost']))))); } // Admin functions $edit_url = new ocp_tempcode(); $add_img_url = new ocp_tempcode(); if (has_actual_page_access(NULL, 'cms_downloads', NULL, NULL) && has_edit_permission('mid', get_member(), $myrow['submitter'], 'cms_downloads', array('downloads', $myrow['category_id']))) { $edit_url = build_url(array('page' => 'cms_downloads', 'type' => '_ed', 'id' => $id), get_module_zone('cms_downloads')); } if (addon_installed('galleries')) { if (has_actual_page_access(NULL, 'cms_galleries', NULL, NULL) && has_edit_permission('mid', get_member(), $myrow['submitter'], 'cms_galleries', array('galleries', 'download_' . strval($id)))) { require_lang('galleries'); $add_img_url = build_url(array('page' => 'cms_galleries', 'type' => 'ad', 'cat' => 'download_' . strval($id)), get_module_zone('cms_galleries')); } } // Outmoding if (!is_null($myrow['out_mode_id'])) { $outmode_url = build_url(array('page' => '_SELF', 'type' => 'entry', 'id' => $myrow['out_mode_id'], 'root' => $root == db_get_first_id() ? NULL : $root), '_SELF'); } else { $outmode_url = new ocp_tempcode(); } // Stats $add_date = get_timezoned_date($myrow['add_date'], false); // Additional information $additional_details = get_translated_tempcode($myrow['comments']); // Edit date if (!is_null($myrow['edit_date'])) { $edit_date = make_string_tempcode(get_timezoned_date($myrow['edit_date'], false)); } else { $edit_date = new ocp_tempcode(); } $images_details = new ocp_tempcode(); $image_url = ''; $counter = 0; if (addon_installed('galleries')) { // Images require_lang('galleries'); $cat = 'download_' . strval($id); $map = array('cat' => $cat); if (!has_specific_permission(get_member(), 'see_unvalidated')) { $map['validated'] = 1; } $rows = $GLOBALS['SITE_DB']->query_select('images', array('*'), $map, 'ORDER BY id', 200); $div = 2; $_out = new ocp_tempcode(); $_row = new ocp_tempcode(); require_code('images'); while (array_key_exists($counter, $rows)) { $row = $rows[$counter]; // $view_url=build_url(array('page'=>'galleries','type'=>'image','wide'=>1,'id'=>$row['id']),get_module_zone('galleries')); $view_url = $row['url']; if ($image_url == '') { $image_url = $row['url']; } if (url_is_local($view_url)) { $view_url = get_custom_base_url() . '/' . $view_url; } $thumb_url = ensure_thumbnail($row['url'], $row['thumb_url'], 'galleries', 'images', $row['id']); $comment = get_translated_tempcode($row['comments']); $thumb = do_image_thumb($thumb_url, ''); if (has_actual_page_access(NULL, 'cms_galleries', NULL, NULL) && has_edit_permission('mid', get_member(), $row['submitter'], 'cms_galleries', array('galleries', 'download_' . strval($id)))) { $iedit_url = build_url(array('page' => 'cms_galleries', 'type' => '_ed', 'id' => $row['id']), get_module_zone('cms_galleries')); } else { $iedit_url = new ocp_tempcode(); } $_content = do_template('DOWNLOAD_SCREEN_IMAGE', array('_GUID' => 'fba0e309aa0ae04891e32c65a625b177', 'ID' => strval($row['id']), 'VIEW_URL' => $view_url, 'EDIT_URL' => $iedit_url, 'THUMB' => $thumb, 'COMMENT' => $comment)); $_row->attach(do_template('DOWNLOAD_GALLERY_IMAGE_CELL', array('_GUID' => '8400a832dbed64bb63f264eb3a038895', 'CONTENT' => $_content))); if ($counter % $div == 1 && $counter != 0) { $_out->attach(do_template('DOWNLOAD_GALLERY_ROW', array('_GUID' => '205c4f5387e98c534d5be1bdfcccdd7d', 'CELLS' => $_row))); $_row = new ocp_tempcode(); } $counter++; } if (!$_row->is_empty()) { $_out->attach(do_template('DOWNLOAD_GALLERY_ROW', array('_GUID' => 'e9667ca2545ac72f85a873f236cbbd6f', 'CELLS' => $_row))); } $images_details = $_out; } // Download link $author = $myrow['author']; $author_url = addon_installed('authors') ? build_url(array('page' => 'authors', 'type' => 'misc', 'id' => $author), get_module_zone('authors')) : new ocp_tempcode(); // Licence $licence_title = NULL; $licence_url = NULL; $licence_hyperlink = NULL; $licence = $myrow['download_licence']; if (!is_null($licence)) { $licence_title = $GLOBALS['SITE_DB']->query_value_null_ok('download_licences', 'l_title', array('id' => $licence)); if (!is_null($licence_title)) { $keep = symbol_tempcode('KEEP'); $licence_url = find_script('download_licence') . '?id=' . strval($licence) . $keep->evaluate(); $licence_hyperlink = do_template('HYPERLINK_POPUP_WINDOW', array('_GUID' => '10582f28c37ee7e9e462fdbd6a2cb8dd', 'TITLE' => '', 'CAPTION' => $licence_title, 'URL' => $licence_url, 'WIDTH' => '600', 'HEIGHT' => '500', 'REL' => 'license')); } else { $licence = NULL; // Orphaned } } breadcrumb_add_segment($tree, $title_to_use); $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $myrow['add_date']), 'creator' => $myrow['author'], 'publisher' => $GLOBALS['FORUM_DRIVER']->get_username($myrow['submitter']), 'modified' => is_null($myrow['edit_date']) ? '' : date('Y-m-d', $myrow['edit_date']), 'type' => 'Download', 'title' => get_translated_text($myrow['name']), 'identifier' => '_SEARCH:downloads:view:' . strval($id), 'description' => get_translated_text($myrow['description']), 'image' => $image_url); return do_template('DOWNLOAD_SCREEN', array('_GUID' => 'a9af438f84783d0d38c20b5f9a62dbdb', 'ORIGINAL_FILENAME' => $myrow['original_filename'], 'URL' => $myrow['url'], 'NUM_IMAGES' => strval($counter), 'TAGS' => get_loaded_tags('downloads'), 'LICENCE' => is_null($licence) ? NULL : strval($licence), 'LICENCE_TITLE' => $licence_title, 'LICENCE_HYPERLINK' => $licence_hyperlink, 'SUBMITTER' => strval($myrow['submitter']), 'EDIT_DATE' => $edit_date, 'EDIT_DATE_RAW' => is_null($myrow['edit_date']) ? '' : strval($myrow['edit_date']), 'VIEWS' => integer_format($myrow['download_views']), 'NAME' => $name, 'DATE' => $add_date, 'DATE_RAW' => strval($myrow['add_date']), 'NUM_DOWNLOADS' => integer_format($myrow['num_downloads']), 'TITLE' => $title, 'OUTMODE_URL' => $outmode_url, 'WARNING_DETAILS' => $warning_details, 'EDIT_URL' => $edit_url, 'ADD_IMG_URL' => $add_img_url, 'DESCRIPTION' => get_translated_tempcode($myrow['description']), 'ADDITIONAL_DETAILS' => $additional_details, 'IMAGES_DETAILS' => $images_details, 'ID' => strval($id), 'FILE_SIZE' => clean_file_size($myrow['file_size']), 'AUTHOR_URL' => $author_url, 'AUTHOR' => $author, 'TRACKBACK_DETAILS' => $trackback_details, 'RATING_DETAILS' => $rating_details, 'COMMENTS_DETAILS' => $comment_details)); }
/** * Get a map between smiley codes and templates representing the HTML-image-code for this smiley. The smilies present of course depend on the forum involved. * * @return array The map */ function find_emoticons() { global $EMOTICON_CACHE; if (!is_null($EMOTICON_CACHE)) { return $EMOTICON_CACHE; } $rows = $this->connection->query_select('smilies', array('*')); $EMOTICON_CACHE = array(); foreach ($rows as $myrow) { $src = str_replace('{imagefolder}' . '/', 'images/', $myrow['smiliepath']); if (url_is_local($src)) { $src = $this->get_emo_dir() . $src; } $EMOTICON_CACHE[$myrow['smiliecode']] = array('EMOTICON_IMG_CODE_DIR', $src, $myrow['smiliecode']); } uksort($EMOTICON_CACHE, 'strlen_sort'); $EMOTICON_CACHE = array_reverse($EMOTICON_CACHE); return $EMOTICON_CACHE; }
/** * Get tempcode for a download 'feature box' for the sgiven row * * @param array The database field row of this download * @param boolean Whether to show a picture * @param boolean Whether to show breadcrumbs * @param ?ID_TEXT The zone the download module we're using is in (NULL: find it) * @param ?string Text summary for result (e.g. highlighted portion of actual file from search result) (NULL: none) * @return tempcode A box for this download, linking to the full download page */ function get_download_html($row, $pic = true, $breadcrumbs = true, $zone = NULL, $text_summary = NULL) { require_css('downloads'); if (is_null($zone)) { $zone = get_module_zone('downloads'); } // Details $filesize = $row['file_size']; $filesize = $filesize > 0 ? clean_file_size($filesize) : do_lang('UNKNOWN'); $description = get_translated_tempcode($row['description']); $root = get_param_integer('root', db_get_first_id(), true); $download_url = build_url(array('page' => 'downloads', 'type' => 'entry', 'id' => $row['id'], 'root' => $root == db_get_first_id() ? NULL : $root), $zone); $date = get_timezoned_date($row['add_date'], false); $date_raw = $row['add_date']; $tree = get_option('show_dload_trees') == '1' && $breadcrumbs ? download_breadcrumbs($row['category_id'], NULL, false, $zone) : new ocp_tempcode(); $pic_suffix = ''; $thumb_url = ''; $full_img_url = ''; if (addon_installed('galleries') && $pic) { // Images $rows = $GLOBALS['SITE_DB']->query_select('images', array('url', 'thumb_url', 'id'), array('cat' => 'download_' . strval($row['id'])), '', 1, $row['default_pic'] - 1); if (array_key_exists(0, $rows)) { $pic_suffix = '_pic'; require_code('images'); $full_img_url = $rows[0]['url']; $thumb_url = ensure_thumbnail($rows[0]['url'], $rows[0]['thumb_url'], 'galleries', 'images', $rows[0]['id']); $imgcode = do_image_thumb($thumb_url, do_lang('DOWNLOAD_THUMBNAIL')); } else { $imgcode = new ocp_tempcode(); } } else { $imgcode = new ocp_tempcode(); } require_code('feedback'); $rating = $row['allow_rating'] == 1 ? display_rating($download_url, get_translated_text($row['name']), 'downloads', strval($row['id']), 'RATING_INLINE_STATIC', $row['submitter']) : NULL; if (!is_null($rating)) { if (trim($rating->evaluate()) == '') { $rating = NULL; } } $licence_title = NULL; $licence_url = NULL; $licence_hyperlink = NULL; $licence = $row['download_licence']; if (!is_null($licence)) { $licence_title = $GLOBALS['SITE_DB']->query_value_null_ok('download_licences', 'l_title', array('id' => $licence)); if (!is_null($licence_title)) { $keep = symbol_tempcode('KEEP'); $licence_url = find_script('download_licence') . '?id=' . strval($licence) . $keep->evaluate(); $licence_hyperlink = do_template('HYPERLINK_POPUP_WINDOW', array('_GUID' => '10582f28c37ee7e9e462fdbd6a2cb8dd', 'TITLE' => '', 'CAPTION' => $licence_title, 'URL' => $licence_url, 'WIDTH' => '600', 'HEIGHT' => '500', 'REL' => 'license')); } else { $licence = NULL; // Orphaned } } // Final template if ($full_img_url != '' && url_is_local($full_img_url)) { $full_img_url = get_custom_base_url() . '/' . $full_img_url; } return do_template('DOWNLOAD_BOX', array('TEXT_SUMMARY' => $text_summary, 'AUTHOR' => $row['author'], 'ID' => strval($row['id']), 'RATING' => $rating, 'VIEWS' => integer_format($row['download_views']), 'SUBMITTER' => strval($row['submitter']), 'DESCRIPTION' => $description, 'FILE_SIZE' => $filesize, 'DOWNLOADS' => integer_format($row['num_downloads']), 'DATE_RAW' => strval($date_raw), 'DATE' => $date, 'EDIT_DATE_RAW' => is_null($row['edit_date']) ? '' : strval($row['edit_date']), 'SIZE' => $filesize, 'URL' => $download_url, 'NAME' => get_translated_text($row['name']), 'TREE' => $tree, 'IMG_URL' => $thumb_url, 'FULL_IMG_URL' => $full_img_url, 'IMGCODE' => $imgcode, 'LICENCE' => is_null($licence) ? NULL : strval($licence), 'LICENCE_TITLE' => $licence_title, 'LICENCE_HYPERLINK' => $licence_hyperlink)); }