/** * Get some forum stats. * * @return array A map of forum stats. */ function ocf_get_forums_stats() { $out = array(); $out['num_topics'] = $GLOBALS['OCF_DRIVER']->get_topics(); $out['num_posts'] = $GLOBALS['OCF_DRIVER']->get_num_forum_posts(); $out['num_members'] = $GLOBALS['OCF_DRIVER']->get_members(); $temp = get_value_newer_than('ocf_newest_member_id', time() - 60 * 60 * 1); $out['newest_member_id'] = is_null($temp) ? NULL : intval($temp); if (!is_null($out['newest_member_id'])) { $out['newest_member_username'] = get_value_newer_than('ocf_newest_member_username', time() - 60 * 60 * 1); } else { $out['newest_member_username'] = NULL; } $out['newest_member_username'] = NULL; if (is_null($out['newest_member_username'])) { $newest_member = $GLOBALS['FORUM_DB']->query('SELECT m_username,id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE m_validated=1 AND id<>' . strval($GLOBALS['FORUM_DRIVER']->get_guest_id()) . ' ORDER BY m_join_time DESC', 1); // Only ordered by m_join_time and not double ordered with ID to make much faster in MySQL $out['newest_member_id'] = $newest_member[0]['id']; $out['newest_member_username'] = $newest_member[0]['m_username']; if (get_db_type() != 'xml') { set_value('ocf_newest_member_id', strval($out['newest_member_id'])); set_value('ocf_newest_member_username', $out['newest_member_username']); } } return $out; }
/** Upgrade database from given version to the latest. */ static function upgrade($country, $version = null) { if ($version === null) { $version = Installer::getVersion(); if ($version === null) { // Assume it's an old v4 with the old id $version = 4; } } while ($version != PT::DB_LEVEL) { $uid = get_user_id(); $type = get_db_type($uid); $pdo = PDOBuilder::getPDO(); // Load generic sql update for current version $file = PT::$ABSPATH . "/install/database/" . $type . "/upgrade-" . $version . ".sql"; $fileContent = \file_get_contents($file); if (!Installer::loadFile($pdo, $fileContent)) { return false; } // Check for localized update data for current version $file = PT::$ABSPATH . "/install/database/" . $type . "upgrade-" . $version . "_" . $country . ".sql"; if (\file_exists($file)) { $fileContent = \file_get_contents($file); if (!Installer::loadFile($pdo, $fileContent)) { return false; } } $version++; } }
/** * Standard modular info function. * * @return ?array Map of module info (NULL: module is disabled). */ function info() { if (get_db_type() != 'mysql') { return NULL; } $info = array(); $info['title'] = do_lang_tempcode('MYSQL_OPTIMISE'); $info['description'] = do_lang_tempcode('DESCRIPTION_MYSQL_OPTIMISE'); $info['type'] = 'optimise'; return $info; }
/** * Standard modular info function. * * @return ?array Map of module info (NULL: module is disabled). */ function info() { if (get_db_type() != 'mysql') { return NULL; } $info = array(); $info['title'] = do_lang_tempcode('CORRECT_MYSQL_SCHEMA_ISSUES'); $info['description'] = do_lang_tempcode('DESCRIPTION_CORRECT_MYSQL_SCHEMA_ISSUES'); $info['type'] = 'optimise'; return $info; }
/** * Standard modular run function for CRON hooks. Searches for tasks to perform. */ function run() { if (get_db_type() == 'oracle') { $oracle_index_cleanup_last_time = intval(get_value('oracle_index_cleanup_last_time')); if ($oracle_index_cleanup_last_time < time() - 60 * 60 * 5) { set_value('oracle_index_cleanup_last_time', strval(time())); $indices = $GLOBALS['SITE_DB']->query_select('db_meta_indices', array('i_name')); foreach ($indices as $index) { if ($index['i_name'][0] == '#') { $GLOBALS['SITE_DB']->query('EXEC CTX_DDL.SYNC_INDEX(\'' . substr($index['i_name'], 1) . '\')'); } } } } }
/** * @license http://opensource.org/licenses/cpal_1.0 Common Public Attribution License * @copyright ocProducts Ltd * @package activity_feed */ function activities_addon_syndicate_described_activity($a_language_string_code = '', $a_label_1 = '', $a_label_2 = '', $a_label_3 = '', $a_pagelink_1 = '', $a_pagelink_2 = '', $a_pagelink_3 = '', $a_addon = '', $a_is_public = 1, $a_member_id = NULL, $sitewide_too = false, $a_also_involving = NULL) { require_code('activities'); require_lang('activities'); if (get_db_type() == 'xml' && get_param_integer('keep_testing_logging', 0) != 1) { return NULL; } $stored_id = 0; if (is_null($a_member_id)) { $a_member_id = get_member(); } if (is_guest($a_member_id)) { return NULL; } $go = array('a_language_string_code' => $a_language_string_code, 'a_label_1' => $a_label_1, 'a_label_2' => $a_label_2, 'a_label_3' => $a_label_3, 'a_is_public' => $a_is_public); $stored_id = mixed(); // Check if this has been posted previously (within the last 10 minutes) to // stop spamming but allow generalised repeat status messages. $test = $GLOBALS['SITE_DB']->query_select('activities', array('a_language_string_code', 'a_label_1', 'a_label_2', 'a_label_3', 'a_is_public'), NULL, 'WHERE a_time>' . strval(time() - 600), 1); if (!array_key_exists(0, $test) || $test[0] != $go || running_script('execute_temp')) { // Log the activity $row = $go + array('a_member_id' => $a_member_id, 'a_also_involving' => $a_also_involving, 'a_pagelink_1' => $a_pagelink_1, 'a_pagelink_2' => $a_pagelink_2, 'a_pagelink_3' => $a_pagelink_3, 'a_time' => time(), 'a_addon' => $a_addon, 'a_is_public' => $a_is_public); $stored_id = $GLOBALS['SITE_DB']->query_insert('activities', $row, true); // Update the latest activity file log_newest_activity($stored_id, 1000); // External places if ($a_is_public == 1 && !$GLOBALS['IS_ACTUALLY_ADMIN']) { $dests = find_all_hooks('systems', 'syndication'); foreach (array_keys($dests) as $hook) { require_code('hooks/systems/syndication/' . $hook); $ob = object_factory('Hook_Syndication_' . $hook); if ($ob->is_available()) { $ob->syndicate_user_activity($a_member_id, $row); if ($sitewide_too && has_specific_permission(get_member(), 'syndicate_site_activity') && post_param_integer('syndicate_this', 0) == 1) { $ob->syndicate_site_activity($row); } } } } list($message) = render_activity($row, false); require_code('notifications'); $username = $GLOBALS['FORUM_DRIVER']->get_username($a_member_id); $subject = do_lang('ACTIVITY_NOTIFICATION_MAIL_SUBJECT', get_site_name(), $username, html_entity_decode(strip_tags($message->evaluate()), ENT_QUOTES, get_charset())); $mail = do_lang('ACTIVITY_NOTIFICATION_MAIL', comcode_escape(get_site_name()), comcode_escape($username), array('[semihtml]' . $message->evaluate() . '[/semihtml]')); dispatch_notification('activity', strval($a_member_id), $subject, $mail); } return $stored_id; }
function import_sql_scripts_to_databases($schema_files, $db_ids, $psa_modify_hash, $db_modify_hash, $settings_modify_hash, $crypt_settings_modify_hash, $settings_enum_modify_hash, $additional_modify_hash) { foreach ($db_ids as $db_id) { if (get_db_type($db_id) != "mysql") { print "FIXME: database type " . get_db_type($db_id) . " is not supported.\n"; exit(1); } foreach ($schema_files as $schema_filename => $schema_db_id) { if ($schema_db_id == $db_id) { mysql_db_connect(get_db_address($db_id), get_db_login($db_id), get_db_password($db_id), get_db_name($db_id)); $sql = modify_content($schema_filename, array_merge($psa_modify_hash, $db_modify_hash, $settings_modify_hash, $settings_enum_modify_hash, $crypt_settings_modify_hash, $additional_modify_hash)); populate_mysql_db($sql); } } } }
/** Get PDO from the loaded database core module */ public static function getPDO($uid = null) { // Set uid to logged user if ($uid === null) { $uid = get_user_id(); } // Return cached pdo if same uid if (PDOBuilder::$pdo !== null && $uid === PDOBuilder::$pdoUid) { return PDOBuilder::$pdo; } $dsn = null; switch (get_db_type($uid)) { case 'mysql': $dsn = "mysql:dbname=" . get_db_name($uid) . ";host=" . get_db_host($uid) . ";port=" . get_db_port($uid); $options = array(\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''); $attributes = array(\PDO::ATTR_CASE => \PDO::CASE_UPPER); break; case 'postgresql': $dsn = "pgsql:dbname=" . get_db_name($uid) . ";host=" . get_db_host($uid) . ";port=" . get_db_port($uid); $options = array(); $attributes = array(\PDO::ATTR_CASE => \PDO::CASE_UPPER); break; default: die("Config error"); } try { PDOBuilder::$pdo = new \PDO($dsn, get_db_user($uid), get_db_password($uid), $options); foreach ($attributes as $key => $value) { PDOBuilder::$pdo->setAttribute($key, $value); } PDOBuilder::$pdoUid = $uid; return PDOBuilder::$pdo; } catch (\PDOException $e) { die("Connexion error " . $e); } }
/** * 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)); }
/** * 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)); }
/** * Display a catalogue entry * * @param AUTO_LINK Entry ID * @param boolean Whether to skip rendering a title * @return tempcode Tempcode interface to display an entry */ function render_catalogue_entry_screen($id, $no_title = false) { require_code('feedback'); if (addon_installed('ecommerce')) { require_code('ecommerce'); } require_code('images'); require_css('catalogues'); require_lang('catalogues'); $entries = $GLOBALS['SITE_DB']->query_select('catalogue_entries', array('*'), array('id' => $id), '', 1); if (!array_key_exists(0, $entries)) { return warn_screen(get_page_title('CATALOGUES'), do_lang_tempcode('MISSING_RESOURCE')); } $entry = $entries[0]; $categories = $GLOBALS['SITE_DB']->query_select('catalogue_categories', array('*'), array('id' => $entry['cc_id']), '', 1); if (!array_key_exists(0, $categories)) { warn_exit(do_lang_tempcode('CAT_NOT_FOUND', strval($entry['cc_id']))); } $category = $categories[0]; $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=catalogues&filter=' . strval($entry['cc_id']); $catalogue_name = $category['c_name']; $catalogues = $GLOBALS['SITE_DB']->query_select('catalogues', array('*'), array('c_name' => $catalogue_name), '', 1); if (!array_key_exists(0, $catalogues)) { warn_exit(do_lang_tempcode('CATALOGUE_NOT_FOUND', $catalogue_name)); } $catalogue = $catalogues[0]; // Permission for here? if (!has_category_access(get_member(), 'catalogues_catalogue', $catalogue_name)) { access_denied('CATALOGUE_ACCESS'); } if (get_value('disable_cat_cat_perms') !== '1' && !has_category_access(get_member(), 'catalogues_category', strval($entry['cc_id']))) { access_denied('CATEGORY_ACCESS'); } $ecommerce = is_ecommerce_catalogue($catalogue_name); if ($ecommerce) { $tpl_set = 'products'; } else { $tpl_set = $catalogue_name; } $root = get_param_integer('root', NULL); $map = get_catalogue_entry_map($entry, $catalogue, 'PAGE', $tpl_set, $root, NULL, NULL, true, true); if (get_db_type() != 'xml') { $entry['ce_views']++; $GLOBALS['SITE_DB']->query_update('catalogue_entries', array('ce_views' => $entry['ce_views']), array('id' => $id), '', 1, NULL, false, true); } // Validation if ($entry['ce_validated'] == 0) { if (!has_specific_permission(get_member(), 'jump_to_unvalidated')) { access_denied('SPECIFIC_PERMISSION', 'jump_to_unvalidated'); } $map['WARNINGS'] = do_template('WARNING_TABLE', array('_GUID' => 'bf604859a572ca53e969bec3d91f9cfb', 'WARNING' => do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT'))); } else { $map['WARNINGS'] = ''; } //Finding any hook exists for this product-------------------- if (addon_installed('ecommerce')) { $object = find_product(strval($id)); if (is_object($object) && method_exists($object, 'get_custom_product_map_fields')) { $object->get_custom_product_map_fields($id, $map); } } //------------------------------------------------------------ $map['ENTRY'] = do_template('CATALOGUE_' . $tpl_set . '_ENTRY', $map, NULL, false, 'CATALOGUE_DEFAULT_ENTRY'); $map['ADD_DATE'] = get_timezoned_date($entry['ce_add_date']); $map['ADD_DATE_RAW'] = strval($entry['ce_add_date']); $map['EDIT_DATE'] = is_null($entry['ce_edit_date']) ? '' : get_timezoned_date($entry['ce_edit_date']); $map['EDIT_DATE_RAW'] = is_null($entry['ce_edit_date']) ? '' : strval($entry['ce_edit_date']); $map['VIEWS'] = integer_format($entry['ce_views']); $title_to_use = do_lang_tempcode($catalogue_name . '__CATALOGUE_ENTRY', $map['FIELD_0']); $title_to_use_2 = do_lang($catalogue_name . '__CATALOGUE_ENTRY', $map['FIELD_0_PLAIN'], NULL, NULL, NULL, false); if (is_null($title_to_use_2)) { $title_to_use = do_lang_tempcode('DEFAULT__CATALOGUE_ENTRY', $map['FIELD_0']); $title_to_use_2 = do_lang('DEFAULT__CATALOGUE_ENTRY', $map['FIELD_0_PLAIN']); } if ($no_title) { $map['TITLE'] = new ocp_tempcode(); } else { if (addon_installed('awards')) { require_code('awards'); $awards = find_awards_for('catalogue_entry', strval($id)); } else { $awards = array(); } $map['TITLE'] = get_page_title($title_to_use, false, NULL, NULL, $awards); } $map['SUBMITTER'] = strval($entry['ce_submitter']); require_code('seo2'); if (is_object($title_to_use_2)) { $title_to_use_2 = $title_to_use_2->evaluate(); } seo_meta_load_for('catalogue_entry', strval($id), strip_tags($title_to_use_2)); if ($map['TREE'] === '') { $map['TREE'] = new ocp_tempcode(); $url = build_url(array('page' => '_SELF', 'type' => 'index', 'id' => $catalogue_name), '_SELF'); $map['TREE']->attach(hyperlink($url, escape_html(get_translated_text($catalogue['c_title'])), false, false, do_lang('INDEX'))); $map['TREE']->attach(do_template('BREADCRUMB_ESCAPED')); $url = build_url(array('page' => '_SELF', 'type' => 'category', 'id' => $category['id']), '_SELF'); $map['TREE']->attach(hyperlink($url, escape_html(get_translated_text($category['cc_title'])), false, false, do_lang('GO_BACKWARDS_TO', get_translated_text($category['cc_title'])), NULL, NULL, 'up')); } $map['CATEGORY_TITLE'] = get_translated_text($category['cc_title']); $map['CAT'] = strval($entry['cc_id']); $map['TAGS'] = get_loaded_tags('catalogue_entries'); breadcrumb_add_segment($map['TREE'], $title_to_use); if (is_null($root)) { breadcrumb_set_parents(array(array('_SELF:_SELF:misc' . ($ecommerce ? ':ecommerce=1' : ''), do_lang('CATALOGUES')))); } $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $entry['ce_add_date']), 'creator' => $GLOBALS['FORUM_DRIVER']->get_username($entry['ce_submitter']), 'publisher' => '', 'modified' => is_null($entry['ce_edit_date']) ? '' : date('Y-m-d', $entry['ce_edit_date']), 'type' => get_translated_text($catalogue['c_title']) . ' entry', 'title' => comcode_escape($title_to_use_2), 'identifier' => '_SEARCH:catalogues:entry:' . strval($id), 'description' => ''); return do_template('CATALOGUE_' . $tpl_set . '_ENTRY_SCREEN', $map, NULL, false, 'CATALOGUE_DEFAULT_ENTRY_SCREEN'); }
/** * Fifth installation step: core tables. * * @return tempcode Progress report / UI */ function step_5_core() { $GLOBALS['SITE_DB']->drop_if_exists('db_meta'); $GLOBALS['SITE_DB']->create_table('db_meta', array('m_table' => '*ID_TEXT', 'm_name' => '*ID_TEXT', 'm_type' => 'ID_TEXT')); $GLOBALS['SITE_DB']->create_index('db_meta', 'findtransfields', array('m_type')); $GLOBALS['SITE_DB']->drop_if_exists('db_meta_indices'); $GLOBALS['SITE_DB']->create_table('db_meta_indices', array('i_table' => '*ID_TEXT', 'i_name' => '*ID_TEXT', 'i_fields' => '*ID_TEXT')); $GLOBALS['SITE_DB']->drop_if_exists('translate'); $GLOBALS['SITE_DB']->create_table('translate', array('id' => '*AUTO', 'language' => '*LANGUAGE_NAME', 'importance_level' => 'SHORT_INTEGER', 'text_original' => 'LONG_TEXT', 'text_parsed' => 'LONG_TEXT', 'broken' => 'BINARY', 'source_user' => 'USER')); $GLOBALS['SITE_DB']->create_index('translate', '#search', array('text_original')); $GLOBALS['SITE_DB']->create_index('translate', 'importance_level', array('importance_level')); //$GLOBALS['SITE_DB']->create_index('translate','id',array('id')); //$GLOBALS['SITE_DB']->create_index('translate','language',array('language')); if (substr(get_db_type(), 0, 5) == 'mysql') { $GLOBALS['SITE_DB']->create_index('translate', 'equiv_lang', array('text_original(4)')); $GLOBALS['SITE_DB']->create_index('translate', 'decache', array('text_parsed(2)')); } $GLOBALS['SITE_DB']->drop_if_exists('values'); $GLOBALS['SITE_DB']->create_table('values', array('the_name' => '*ID_TEXT', 'the_value' => 'ID_TEXT', 'date_and_time' => 'TIME')); $GLOBALS['SITE_DB']->create_index('values', 'date_and_time', array('date_and_time')); $GLOBALS['SITE_DB']->drop_if_exists('config'); $GLOBALS['SITE_DB']->create_table('config', array('the_name' => '*ID_TEXT', 'human_name' => 'ID_TEXT', 'c_set' => 'BINARY', 'config_value' => 'LONG_TEXT', 'the_type' => 'ID_TEXT', 'eval' => 'SHORT_TEXT', 'the_page' => 'ID_TEXT', 'section' => 'ID_TEXT', 'explanation' => 'ID_TEXT', 'shared_hosting_restricted' => 'BINARY', 'c_data' => 'SHORT_TEXT')); // Privileges $GLOBALS['SITE_DB']->drop_if_exists('gsp'); $GLOBALS['SITE_DB']->create_table('gsp', array('group_id' => '*INTEGER', 'specific_permission' => '*ID_TEXT', 'the_page' => '*ID_TEXT', 'module_the_name' => '*ID_TEXT', 'category_name' => '*ID_TEXT', 'the_value' => 'BINARY')); $GLOBALS['SITE_DB']->drop_if_exists('sp_list'); $GLOBALS['SITE_DB']->create_table('sp_list', array('p_section' => 'ID_TEXT', 'the_name' => '*ID_TEXT', 'the_default' => '*BINARY')); $GLOBALS['SITE_DB']->drop_if_exists('attachments'); $GLOBALS['SITE_DB']->create_table('attachments', array('id' => '*AUTO', 'a_member_id' => 'USER', 'a_file_size' => '?INTEGER', 'a_url' => 'SHORT_TEXT', 'a_description' => 'SHORT_TEXT', 'a_thumb_url' => 'SHORT_TEXT', 'a_original_filename' => 'SHORT_TEXT', 'a_num_downloads' => 'INTEGER', 'a_last_downloaded_time' => '?INTEGER', 'a_add_time' => 'INTEGER')); $GLOBALS['SITE_DB']->drop_if_exists('attachment_refs'); $GLOBALS['SITE_DB']->create_table('attachment_refs', array('id' => '*AUTO', 'r_referer_type' => 'ID_TEXT', 'r_referer_id' => 'ID_TEXT', 'a_id' => 'AUTO_LINK')); $GLOBALS['SITE_DB']->create_index('attachments', 'ownedattachments', array('a_member_id')); $GLOBALS['SITE_DB']->create_index('attachments', 'attachmentlimitcheck', array('a_add_time')); return do_template('INSTALLER_DONE_SOMETHING', array('_GUID' => 'c6b6d92c670b7f1b223798ace54102f9', 'SOMETHING' => do_lang_tempcode('PRIMARY_CORE_INSTALLED'))); }
/** * The UI to view subscribers on the newsletter. * * @return tempcode The UI */ function view_subscribers() { $title = get_page_title('VIEW_NEWSLETTER_SUBSCRIBERS'); $lang = choose_language($title); if (is_object($lang)) { return $lang; } $id = either_param('id', NULL); $level = get_param_integer('level', NULL); require_lang('ocf'); // Select newsletter if (is_null($id)) { $fields = new ocp_tempcode(); require_code('form_templates'); // Selection $newsletters = new ocp_tempcode(); $rows = $GLOBALS['SITE_DB']->query_select('newsletters', array('id', 'title')); foreach ($rows as $newsletter) { $newsletters->attach(form_input_list_entry(strval($newsletter['id']), false, get_translated_text($newsletter['title']))); } if (get_forum_type() == 'ocf') { $newsletters->attach(form_input_list_entry('-1', false, do_lang_tempcode('NEWSLETTER_OCF'))); $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(); foreach ($groups as $group_id => $group) { if ($group_id != db_get_first_id()) { $map = array(); $map['g' . strval($group_id)] = 1; $_c = newsletter_who_send_to($map, $lang, 0, 0); $c6 = $_c[6]['g' . strval($group_id)]; if ($c6 != 0) { $newsletters->attach(form_input_list_entry('g' . strval($group_id), false, do_lang_tempcode('THIS_WITH', do_lang_tempcode('GROUP'), make_string_tempcode(escape_html($group))))); } } } } if ($newsletters->is_empty()) { inform_exit(do_lang_tempcode('NO_CATEGORIES')); } $fields->attach(form_input_list(do_lang_tempcode('NEWSLETTER'), '', 'id', $newsletters)); // CSV option $fields->attach(form_input_tick(do_lang_tempcode('DOWNLOAD_AS_CSV'), do_lang_tempcode('DESCRIPTION_DOWNLOAD_AS_CSV'), 'csv', false)); $submit_name = do_lang_tempcode('VIEW_SUBSCRIBERS'); $post_url = get_self_url(); $prune_url = build_url(array('page' => '_SELF', 'type' => 'bounce_filter_a'), '_SELF'); return do_template('FORM_SCREEN', array('GET' => true, 'SKIP_VALIDATION' => true, 'HIDDEN' => '', 'TITLE' => $title, 'TEXT' => do_lang_tempcode('NEWSLETTER_SUBSCRIBERS_FORM', escape_html($prune_url->evaluate())), 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url)); } // Send to CSV file? $csv = either_param_integer('csv', 0); if ($csv == 1) { $filename = 'subscribers_' . $id . '.csv'; header('Content-type: text/csv'); if (strstr(ocp_srv('HTTP_USER_AGENT'), 'MSIE') !== false) { header('Content-Disposition: filename="' . str_replace(chr(13), '', str_replace(chr(10), '', addslashes($filename))) . '"'); } else { header('Content-Disposition: attachment; filename="' . str_replace(chr(13), '', str_replace(chr(10), '', addslashes($filename))) . '"'); } @ini_set('ocproducts.xss_detect', '0'); } // Show subscribers $levels = is_null($level) ? $id == '-1' || substr($id, 0, 1) == 'g' ? array(4) : array(1, 2, 3, 4) : array($level); $outs = array(); foreach ($levels as $level) { $max = get_param_integer('max_' . (is_null($level) ? '' : strval($level)), 100); $start = get_param_integer('start_' . (is_null($level) ? '' : strval($level)), 0); $max_rows = 0; if (is_null($level)) { $map[$id] = 1; // $id will be -1 $_c = newsletter_who_send_to($map, $lang, 0, 0, true); if (isset($_c[6][$id])) { $max_rows = $_c[6][$id]; } } else { $map[$id] = $level; // We're requesting that we probe subscribers of $id on $level $_c = newsletter_who_send_to($map, $lang, 0, 0, true); if (isset($_c[6][$id])) { $max_rows = $_c[6][$id]; } } $num = 0; $start2 = 0; do { $map = array(); if (is_null($level)) { $map[$id] = 1; // $id will be -1 $_c = newsletter_who_send_to($map, $lang, $start + $start2, $max, true); } else { $map[$id] = $level; // We're requesting that we probe subscribers of $id on $level $_c = newsletter_who_send_to($map, $lang, $start + $start2, $max, true); } $rows = $_c[7]; if ($csv == 1) { if ($start2 == 0) { if (!is_null($level)) { echo '"LEVEL ' . do_lang('NEWSLETTER_' . strval($level)) . '"' . chr(10); } echo '"' . str_replace('"', '""', do_lang('EMAIL_ADDRESS')) . '",' . '"' . str_replace('"', '""', do_lang('FORENAME')) . '",' . '"' . str_replace('"', '""', do_lang('SURNAME')) . '",' . '"' . str_replace('"', '""', do_lang('NAME')) . '",' . '"' . str_replace('"', '""', do_lang('NEWSLETTER_SEND_ID')) . '",' . '"' . str_replace('"', '""', do_lang('NEWSLETTER_HASH')) . '",' . '"' . str_replace('"', '""', do_lang('PASSWORD_HASH')) . '",' . '"' . str_replace('"', '""', do_lang('SALT')) . '",' . '"' . str_replace('"', '""', do_lang('LANGUAGE')) . '",' . '"' . str_replace('"', '""', do_lang('CONFIRM_CODE')) . '",' . '"' . str_replace('"', '""', do_lang('JOIN_DATE')) . '"' . chr(10); } } else { $out = ''; } foreach ($rows as $r) { $email = array_key_exists('email', $r) ? $r['email'] : $r['m_email_address']; $forename = array_key_exists('n_forename', $r) ? $r['n_forename'] : ''; $surname = array_key_exists('n_surname', $r) ? $r['n_surname'] : ''; $name = array_key_exists('m_username', $r) ? $r['m_username'] : ''; $salt = array_key_exists('pass_salt', $r) ? $r['pass_salt'] : ''; $_lang = array_key_exists('language', $r) ? $r['language'] : ''; $confirm_code = array_key_exists('confirm_code', $r) ? $r['confirm_code'] : 0; $join_time = array_key_exists('join_time', $r) ? $r['join_time'] : time(); $send_id = (array_key_exists('m_username', $r) ? 'm' : 'n') . (array_key_exists('id', $r) ? strval($r['id']) : $email); $hash = array_key_exists('the_password', $r) ? $r['the_password'] : ''; $unsub = array_key_exists('the_password', $r) ? best_hash($r['the_password'], 'xunsub') : ''; if ($csv == 1) { echo '"' . str_replace('"', '""', $email) . '",' . '"' . str_replace('"', '""', $forename) . '",' . '"' . str_replace('"', '""', $surname) . '",' . '"' . str_replace('"', '""', $name) . '",' . '"' . str_replace('"', '""', $send_id) . '",' . '"' . str_replace('"', '""', $unsub) . '",' . '"' . str_replace('"', '""', $hash) . '",' . '"' . str_replace('"', '""', $salt) . '",' . '"' . str_replace('"', '""', $_lang) . '",' . '"' . str_replace('"', '""', strval($confirm_code)) . '",' . '"' . str_replace('"', '""', date('Y-m-d h:i:s', $join_time)) . '"' . chr(10); } else { $tpl = do_template('NEWSLETTER_SUBSCRIBER', array('EMAIL' => $email, 'FORENAME' => $forename, 'SURNAME' => $surname, 'NAME' => $name, 'NEWSLETTER_SEND_ID' => $send_id, 'NEWSLETTER_HASH' => $hash)); $out .= $tpl->evaluate(); } } $start2 += $max; } while ($csv == 1 && array_key_exists(0, $rows)); if (count($rows) == 0 && $start2 == 0) { if ($csv == 1) { echo '"(' . do_lang('NONE') . ')"' . chr(10); } else { } } $text = do_lang_tempcode('NEWSLETTER_PEOPLE_ON_LEVEL', is_numeric($level) && intval($level) > 0 ? make_string_tempcode(escape_html(do_lang('NEWSLETTER_' . strval($level)))) : do_lang_tempcode('NA_EM')); if ($csv == 1) { } else { require_code('templates_results_browser'); $results_browser = results_browser(do_lang_tempcode('VIEW_NEWSLETTER_SUBSCRIBERS'), NULL, $start, 'start_' . (is_null($level) ? '' : strval($level)), $max, 'max_' . (is_null($level) ? '' : strval($level)), $max_rows, NULL, 'subscribers', true); $outs[] = array('RESULTS_BROWSER' => $results_browser, 'SUB' => $out, 'TEXT' => $text); } } if ($csv == 1) { $GLOBALS['SCREEN_TEMPLATE_CALLED'] = ''; exit; } // Work out stats of what domains are used $domains = array(); $start = 0; do { if (strpos(get_db_type(), 'mysql') !== false) { $rows = $GLOBALS['SITE_DB']->query_select('newsletter', array('email', 'COUNT(*) as cnt'), NULL, 'GROUP BY SUBSTRING_INDEX(email,\'@\',-1)'); // Far less PHP processing } else { $rows = $GLOBALS['SITE_DB']->query_select('newsletter', array('email'), NULL, 500, $start); } foreach ($rows as $row) { $email = $row['email']; if (strpos($email, '@') === false) { continue; } $domain = substr($email, strpos($email, '@') + 1); if (!is_string($domain)) { continue; } $cnt = array_key_exists('cnt', $row) ? $row['cnt'] : 1; if (!array_key_exists($domain, $domains)) { $domains[$domain] = 0; } $domains[$domain] += $cnt; } $start += 500; } while (array_key_exists(0, $rows) && strpos(get_db_type(), 'mysql') === false); arsort($domains); foreach ($domains as $key => $val) { $domains[$key] = strval($val); if (count($domains) > 100) { if ($val == 1) { unset($domains[$key]); } } } return do_template('NEWSLETTER_SUBSCRIBERS_SCREEN', array('_GUID' => '52e5d97d451b622d59f87f021a5b8f01', 'DOMAINS' => $domains, 'SUBSCRIBERS' => $outs, 'TITLE' => $title)); }
function get_db_modify_hash($db_ids) { $parameters = array(); foreach ($db_ids as $db_id) { $parameters["@@" . "DB_" . strtoupper($db_id) . "_TYPE" . "@@"] = get_db_type($db_id); $parameters["@@" . "DB_" . strtoupper($db_id) . "_NAME" . "@@"] = get_db_name($db_id); $parameters["@@" . "DB_" . strtoupper($db_id) . "_LOGIN" . "@@"] = get_db_login($db_id); $parameters["@@" . "DB_" . strtoupper($db_id) . "_PASSWORD" . "@@"] = get_db_password($db_id); $parameters["@@" . "DB_" . strtoupper($db_id) . "_HOST" . "@@"] = fetch_env_var("DB_{$db_id}_HOST"); $parameters["@@" . "DB_" . strtoupper($db_id) . "_VERSION" . "@@"] = fetch_env_var("DB_{$db_id}_VERSION"); $parameters["@@" . "DB_" . strtoupper($db_id) . "_PORT" . "@@"] = fetch_env_var("DB_{$db_id}_PORT"); $parameters["@@" . "DB_" . strtoupper($db_id) . "_PREFIX" . "@@"] = get_db_prefix($db_id); $parameters["@@" . "DB_" . strtoupper($db_id) . "_ADDRESS" . "@@"] = get_db_address($db_id); } return $parameters; }
/** * 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)); }
/** * Get an array of maps for the topic in the given forum. * * @param object Link to the real forum driver * @param integer The topic ID * @param integer The comment count will be returned here by reference * @param ?integer Maximum comments to returned (NULL: no limit) * @param integer Comment to start at * @param boolean Whether to mark the topic read * @param boolean Whether to show in reverse * @param boolean Whether to only load minimal details if it is a threaded topic * @param ?array List of post IDs to load (NULL: no filter) * @param boolean Whether to load spacer posts * @return mixed The array of maps (Each map is: title, message, member, date) (-1 for no such forum, -2 for no such topic) */ function _helper_get_forum_topic_posts($this_ref, $topic_id, &$count, $max, $start, $mark_read = true, $reverse = false, $light_if_threaded = false, $post_ids = NULL, $load_spacer_posts_too = false) { if (is_null($topic_id)) { $count = 0; return -2; } require_code('ocf_topics'); $is_threaded = $this_ref->topic_is_threaded($topic_id); $extra_where = ''; if (!is_null($post_ids)) { if (count($post_ids) == 0) { $count = 0; return array(); } $extra_where = ' AND ('; foreach ($post_ids as $i => $id) { if ($i != 0) { $extra_where .= ' OR '; } $extra_where .= 'p.id=' . strval($id); } $extra_where .= ')'; } $where = '(' . ocf_get_topic_where($topic_id) . ')'; if (!$load_spacer_posts_too) { $where .= not_like_spacer_posts('t.text_original'); } $where .= $extra_where; if (!has_specific_permission(get_member(), 'see_unvalidated')) { $where .= ' AND (p_validated=1 OR ((p_poster<>' . strval($GLOBALS['FORUM_DRIVER']->get_guest_id()) . ' OR ' . db_string_equal_to('p_ip_address', get_ip_address()) . ') AND p_poster=' . strval((int) get_member()) . '))'; } $index = strpos(get_db_type(), 'mysql') !== false && !is_null($GLOBALS['SITE_DB']->query_value_null_ok('db_meta_indices', 'i_name', array('i_table' => 'f_posts', 'i_name' => 'in_topic'))) ? 'USE INDEX (in_topic)' : ''; $order = $reverse ? 'p_time DESC,p.id DESC' : 'p_time ASC,p.id ASC'; if ($is_threaded && db_has_subqueries($this_ref->connection->connection_read)) { $order = ($reverse ? 'compound_rating ASC' : 'compound_rating DESC') . ',' . $order; } if ($light_if_threaded && $is_threaded) { $select = 'p.id,p.p_parent_id,p.p_intended_solely_for,p.p_poster'; } else { $select = 'p.*,text_parsed,text_original'; if (!db_has_subqueries($GLOBALS['FORUM_DB']->connection_read)) { $select .= ',h.h_post_id'; } } if ($is_threaded && db_has_subqueries($this_ref->connection->connection_read)) { $select .= ',COALESCE((SELECT AVG(rating) FROM ' . $this_ref->connection->get_table_prefix() . 'rating WHERE ' . db_string_equal_to('rating_for_type', 'post') . ' AND rating_for_id=p.id),5) AS compound_rating'; } if (!db_has_subqueries($GLOBALS['FORUM_DB']->connection_read)) { $rows = $this_ref->connection->query('SELECT ' . $select . ' FROM ' . $this_ref->connection->get_table_prefix() . 'f_posts p ' . $index . ' LEFT JOIN ' . $this_ref->connection->get_table_prefix() . 'translate t ON t.id=p.p_post LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_post_history h ON (h.h_post_id=p.id AND h.h_action_date_and_time=p.p_last_edit_time) WHERE ' . $where . ' ORDER BY ' . $order, $max, $start); } else { $rows = $this_ref->connection->query('SELECT ' . $select . ', (SELECT h_post_id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_post_history h WHERE (h.h_post_id=p.id) LIMIT 1) AS h_post_id FROM ' . $this_ref->connection->get_table_prefix() . 'f_posts p ' . $index . ' LEFT JOIN ' . $this_ref->connection->get_table_prefix() . 'translate t ON t.id=p.p_post WHERE ' . $where . ' ORDER BY ' . $order, $max, $start); } $count = $this_ref->connection->query_value_null_ok_full('SELECT COUNT(*) FROM ' . $this_ref->connection->get_table_prefix() . 'f_posts p ' . $index . ' LEFT JOIN ' . $this_ref->connection->get_table_prefix() . 'translate t ON t.id=p.p_post WHERE ' . $where); $out = array(); foreach ($rows as $myrow) { if (is_null($myrow['p_intended_solely_for']) || $myrow['p_intended_solely_for'] == get_member() || $myrow['p_intended_solely_for'] == $this_ref->get_guest_id() && $this_ref->is_staff(get_member())) { $temp = $myrow; // Takes all OCF properties // Then sanitised for normal forum driver API too (involves repetition) $temp['parent_id'] = $myrow['p_parent_id']; if (!$light_if_threaded || !$is_threaded) { $temp['title'] = $myrow['p_title']; $message = new ocp_tempcode(); if (get_page_name() == 'search' || is_null($myrow['text_parsed']) || $myrow['text_parsed'] == '' || $myrow['p_post'] == 0) { $message = get_translated_tempcode($myrow['p_post'], $GLOBALS['FORUM_DB']); } else { if (!$message->from_assembly($myrow['text_parsed'], true)) { $message = get_translated_tempcode($myrow['p_post'], $GLOBALS['FORUM_DB']); } } $temp['message'] = $message; $temp['message_comcode'] = get_translated_text($myrow['p_post'], $GLOBALS['FORUM_DB']); $temp['user'] = $myrow['p_poster']; if ($myrow['p_poster_name_if_guest'] != '') { $temp['username'] = $myrow['p_poster_name_if_guest']; } $temp['date'] = $myrow['p_time']; } $out[] = $temp; } } if ($mark_read) { require_code('ocf_topics'); ocf_ping_topic_read($topic_id); } return $out; }