/** * This function creates a Group of Overlay Form * * Creates a Form for a group of overlay using the supplied defaults (if specified). * * @param array $group array of values describing a group of overlay * @return string HTML string of overlay form */ function MAPS_getGroupOverlayForm($group = array()) { global $_CONF, $_TABLES, $_MAPS_CONF, $LANG_MAPS_1, $LANG_configselects, $LANG_ACCESS, $_USER, $_GROUPS, $_SCRIPTS; $display = COM_startBlock('<h1>' . $LANG_MAPS_1['group_edit'] . ' ' . $group['o_group_name'] . '</h1>'); $template = COM_newTemplate($_CONF['path'] . 'plugins/maps/templates'); $template->set_file(array('map' => 'group_overlay_form.thtml')); $template->set_var('yes', $LANG_MAPS_1['yes']); $template->set_var('no', $LANG_MAPS_1['no']); //informations $template->set_var('group_overlay_presentation', $LANG_MAPS_1['group_overlay_presentation']); $template->set_var('informations', $LANG_MAPS_1['informations']); $template->set_var('name_label', $LANG_MAPS_1['group_overlay_name_label']); $template->set_var('name', stripslashes($group['o_group_name'])); $template->set_var('required_field', $LANG_MAPS_1['required_field']); //Form validation $template->set_var('save_button', $LANG_MAPS_1['save_button']); if ($group['o_group_id'] > 0) { $template->set_var('delete_button', '<option value="delete">' . $LANG_MAPS_1['delete_button'] . '</option>'); } else { $template->set_var('delete_button', ''); } $template->set_var('ok_button', $LANG_MAPS_1['ok_button']); if (isset($group['o_group_id'])) { $template->set_var('o_group_id', '<input type="hidden" name="o_group_id" value="' . $group['o_group_id'] . '" />'); } else { $template->set_var('o_group_id', ''); } $display .= $template->parse('output', 'map'); $display .= COM_endBlock(); return $display; }
/** * Shows the URL routing editor * This will show a URL routing edit form. * * @param int $rid ID of URL routing rule to edit * @return string HTML for URL routing editor */ function getRouteEditor($rid = 0) { global $_CONF, $_TABLES, $LANG_ROUTER, $LANG_ADMIN, $MESSAGE, $securityToken; $retval = ''; $A = array('rid' => $rid, 'method' => Router::HTTP_REQUEST_GET, 'rule' => '', 'route' => '', 'priority' => Router::DEFAULT_PRIORITY); $rid = intval($rid, 10); if ($rid > 0) { if (DB_count($_TABLES['routes'], 'rid', $rid) == 1) { $sql = "SELECT * FROM {$_TABLES['routes']} WHERE rid =" . DB_escapeString($rid); $result = DB_query($sql); $A = DB_fetchArray($result); } else { // Non-existent route $rid = 0; $A['rid'] = $rid; } } $T = COM_newTemplate($_CONF['path_layout'] . 'admin/router'); $T->set_file('editor', 'routereditor.thtml'); $routerStart = COM_startBlock($LANG_ROUTER[10], '', COM_getBlockTemplate('_admin_block', 'header')) . LB . SEC_getTokenExpiryNotice($securityToken); $T->set_var('start_router_editor', $routerStart); if ($rid > 0) { $deleteButton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="mode"%s' . XHTML . '>'; $jsConfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"'; $T->set_var(array('delete_option' => sprintf($deleteButton, $jsConfirm), 'delete_option_no_confirmation' => sprintf($deleteButton, ''), 'allow_delete' => true)); } $T->set_var(array('rid' => $A['rid'], 'method' => $A['method'], 'rule' => $A['rule'], 'route' => $A['route'], 'priority' => $A['priority'], 'gltoken_name' => CSRF_TOKEN, 'gltoken' => $securityToken)); $T->set_var(array('lang_router_rid' => $LANG_ROUTER[3], 'lang_router_method' => $LANG_ROUTER[4], 'lang_router_rule' => $LANG_ROUTER[5], 'lang_router_route' => $LANG_ROUTER[6], 'lang_router_priority' => $LANG_ROUTER[7], 'lang_router_notice' => $LANG_ROUTER[20], 'lang_save' => $LANG_ADMIN['save'], 'lang_cancel' => $LANG_ADMIN['cancel'], 'lang_delete' => $LANG_ADMIN['delete'], 'confirm_message' => $MESSAGE[76])); $T->set_var('end_block', COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'))); $T->parse('output', 'editor'); $retval .= $T->finish($T->get_var('output')); return $retval; }
function MG_enroll() { global $_CONF, $_MG_CONF, $_TABLES, $_USER, $LANG_MG03; // let's make sure this user does not already have a member album if ($_MG_CONF['member_albums'] != 1) { echo COM_refresh($_MG_CONF['site_url'] . '/index.php'); exit; } $sql = "SELECT album_id FROM {$_TABLES['mg_albums']} " . "WHERE owner_id=" . intval($_USER['uid']) . " AND album_parent=" . intval($_MG_CONF['member_album_root']); $result = DB_query($sql); $nRows = DB_numRows($result); if ($nRows > 0) { $display = COM_startBlock('', '', COM_getBlockTemplate('_msg_block', 'header')); $display .= $LANG_MG03['existing_member_album']; $display .= COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer')); $display = MG_createHTMLDocument($display); COM_output($display); exit; } $T = COM_newTemplate(MG_getTemplatePath(0)); $T->set_file('enroll', 'enroll.thtml'); $T->set_var(array('s_form_action' => $_MG_CONF['site_url'] . '/enroll.php', 'lang_title' => $LANG_MG03['enroll_title'], 'lang_overview' => $LANG_MG03['overview'], 'lang_terms' => $LANG_MG03['terms'], 'lang_member_album_overview' => $LANG_MG03['member_album_overview'], 'lang_member_album_terms' => $LANG_MG03['member_album_terms'], 'lang_agree' => $LANG_MG03['agree'], 'lang_cancel' => $LANG_MG03['cancel'])); $retval .= $T->finish($T->parse('output', 'enroll')); return $retval; }
function adminfooter() { global $_CONF, $LANG_GF01, $CONF_FORUM; $footertemplate = COM_newTemplate($CONF_FORUM['path_layout'] . 'forum/layout/admin'); $footertemplate->set_file(array('footertemplate' => 'footer.thtml')); $footertemplate->set_var('forumname', $LANG_GF01['forumname']); $footertemplate->parse('output', 'footertemplate'); return $footertemplate->finish($footertemplate->get_var('output')); }
/** * List all markers that the user has access to * * @retun string HTML for the list * */ function MAPS_listUserMarkers() { global $_CONF, $_USER, $_MAPS_CONF, $_TABLES, $_IMAGE_TYPE, $LANG_ADMIN, $LANG_MAPS_1, $LANG_LOGIN; require_once $_CONF['path_system'] . 'lib-admin.php'; $retval = ''; if (COM_isAnonUser()) { $retval .= COM_startBlock($LANG_LOGIN[1], '', COM_getBlockTemplate('_msg_block', 'header')); $login = COM_newTemplate($_CONF['path'] . 'plugins/maps/templates'); $login->set_file(array('login' => 'submitloginrequired.thtml')); $login->set_var('xhtml', XHTML); $login->set_var('login_message', $LANG_LOGIN[2]); $login->set_var('site_url', $_CONF['site_url']); $login->set_var('site_admin_url', $_CONF['site_admin_url']); $login->set_var('layout_url', $_CONF['layout_url']); $login->set_var('lang_login', $LANG_LOGIN[3]); $login->set_var('lang_newuser', $LANG_LOGIN[4]); $login->parse('output', 'login'); $retval .= $login->finish($login->get_var('output')); $retval .= COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer')); return $retval; } $uid = $_USER['uid']; if (DB_count($_TABLES['maps_markers'], 'owner_id', $uid) == 0) { return $retval = $LANG_MAPS_1['no_marker']; } if ($_MAPS_CONF['monetize'] == 1) { $header_arr = array(array('text' => $LANG_MAPS_1['name'], 'field' => 'name', 'sort' => true), array('text' => $LANG_MAPS_1['address'], 'field' => 'address', 'sort' => false), array('text' => $LANG_MAPS_1['to_label'], 'field' => 'to', 'sort' => true), array('text' => $LANG_MAPS_1['id'], 'field' => 'mkid', 'sort' => true)); } else { $header_arr = array(array('text' => $LANG_MAPS_1['name'], 'field' => 'name', 'sort' => true), array('text' => $LANG_MAPS_1['address'], 'field' => 'address', 'sort' => false), array('text' => $LANG_MAPS_1['id'], 'field' => 'mkid', 'sort' => true)); } if ($_MAPS_CONF['marker_edition'] == 1 || SEC_hasRights('maps.admin')) { $header_arr[] = array('text' => $LANG_ADMIN['edit'], 'field' => 'edit', 'sort' => false); } $defsort_arr = array('field' => 'mk.name', 'direction' => 'asc'); $text_arr = array('has_extras' => true, 'form_url' => $_MAPS_CONF['site_url'] . '/markers.php'); $sql = "SELECT\n\t mk.*, m.free_marker\n FROM {$_TABLES['maps_markers']} AS mk\n\t\t\tLEFT JOIN {$_TABLES['maps_maps']} AS m\n\t\t\t\t ON mk.mid = m.mid"; $query_arr = array('table' => 'maps_markers', 'sql' => $sql, 'query_fields' => array('mk.name'), 'default_filter' => 'WHERE mk.owner_id=' . $uid); $retval .= ADMIN_list('markers', 'plugin_getListField_userMarkers', $header_arr, $text_arr, $query_arr, $defsort_arr); return $retval; }
/** * This function creates an import Form * * @return string HTML string of form */ function getImportExportForm() { global $_CONF, $_TABLES, $LANG_MAPS_1; $return = COM_startBlock($LANG_MAPS_1['import_export']); $template = COM_newTemplate($_CONF['path'] . 'plugins/maps/templates'); $template->set_file(array('import_export' => 'import_export_form.thtml')); $template->set_var('site_admin_url', $_CONF['site_admin_url']); $template->set_var('import', $LANG_MAPS_1['import']); $template->set_var('import_message', $LANG_MAPS_1['import_message']); $template->set_var('export', $LANG_MAPS_1['export']); $template->set_var('export_message', $LANG_MAPS_1['export_message']); $template->set_var('select_file', $LANG_MAPS_1['select_file']); //delimiters $template->set_var('separator_in', $LANG_MAPS_1['separator']); $template->set_var('separator_out', $LANG_MAPS_1['separator']); $separator_options = '<option value=";">;</option>' . LB; $separator_options .= '<option value="tab">tab</option>' . LB; $separator_options .= '<option value=",">,</option>' . LB; $template->set_var('separator_options_in', $separator_options); $template->set_var('separator_options_out', $separator_options); //select map $template->set_var('mid_label', $LANG_MAPS_1['name_label']); $map_options = MAPS_recurseMaps($marker['mid']); $template->set_var('map_options', $map_options); //Fields to import or export $template->set_var('choose_fields_import', $LANG_MAPS_1['choose_fields_import']); $template->set_var('choose_fields_export', $LANG_MAPS_1['choose_fields_export']); $template->set_var('checkall', $LANG_MAPS_1['checkall']); $valid_fieds = MAPS_getFieldsImportExport(); foreach ($valid_fieds as $value) { $fields_selector .= '<input type="checkbox" name="import_export[]" value="' . $value . '" />' . $value . '<br' . XHTML . '>' . LB; } $template->set_var('fields_selector', $fields_selector); //Form validation $template->set_var('ok_button', $LANG_MAPS_1['ok_button']); $return .= $template->parse('output', 'import_export'); $return .= COM_endBlock(); return $return; }
/** * Show topic administration form * * @param string tid ID of topic to edit * @return string HTML for the topic editor */ function edittopic($tid = '') { global $_CONF, $_GROUPS, $_TABLES, $_USER, $LANG04, $LANG27, $LANG_ACCESS, $LANG_ADMIN, $MESSAGE, $_SCRIPTS; $retval = ''; if (empty($tid)) { // new topic - set defaults $A = array('tid' => '', 'topic' => '', 'sortnum' => 0, 'parent_id' => TOPIC_ROOT, 'inherit' => 1, 'hidden' => 0, 'limitnews' => '', 'is_default' => 0, 'archive_flag' => 0); } else { $result = DB_query("SELECT * FROM {$_TABLES['topics']} WHERE tid ='{$tid}'"); $A = DB_fetchArray($result); $access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']); if ($access == 0 || $access == 2) { $retval .= COM_showMessageText($LANG27[13], $LANG27[12]); COM_accessLog("User {$_USER['username']} tried to illegally create or edit topic {$tid}."); return $retval; } } $token = SEC_createToken(); $retval .= COM_startBlock($LANG27[1], '', COM_getBlockTemplate('_admin_block', 'header')); $retval .= SEC_getTokenExpiryNotice($token); if (!is_array($A) || empty($A['owner_id'])) { $A['owner_id'] = $_USER['uid']; // this is the one instance where we default the group // most topics should belong to the Topic Admin group if (isset($_GROUPS['Topic Admin'])) { $A['group_id'] = $_GROUPS['Topic Admin']; } else { $A['group_id'] = SEC_getFeatureGroup('topic.edit'); } SEC_setDefaultPermissions($A, $_CONF['default_permissions_topic']); $access = 3; } $topic_templates = COM_newTemplate($_CONF['path_layout'] . 'admin/topic'); $topic_templates->set_file('editor', 'topiceditor.thtml'); if (!empty($tid) && SEC_hasRights('topic.edit')) { $delButton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="mode"%s' . XHTML . '>'; $jsConfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"'; $topic_templates->set_var('delete_option', sprintf($delButton, $jsConfirm)); $topic_templates->set_var('delete_option_no_confirmation', sprintf($delButton, '')); $topic_templates->set_var('allow_delete', true); $topic_templates->set_var('lang_delete', $LANG_ADMIN['delete']); $topic_templates->set_var('confirm_message', $MESSAGE[76]); $topic_templates->set_var('warning_msg', $LANG27[6]); } if ($_CONF['titletoid'] && empty($tid)) { $_SCRIPTS->setJavaScriptFile('title_2_id', '/javascript/title_2_id.js'); $topic_templates->set_var('titletoid', true); } $topic_templates->set_var('lang_topicid', $LANG27[2]); $topic_templates->set_var('topic_id', $A['tid']); $topic_templates->set_var('lang_parent_id', $LANG27[32]); $topic_templates->set_var('parent_id_options', TOPIC_getTopicListSelect($A['parent_id'], 1, false, $A['tid'], true)); $topic_templates->set_var('lang_inherit', $LANG27[33]); $topic_templates->set_var('lang_inherit_info', $LANG27[34]); if ($A['inherit'] == 1) { $topic_templates->set_var('inherit_checked', 'checked="checked"'); } else { $topic_templates->set_var('inherit_checked', ''); } $topic_templates->set_var('lang_hidden', $LANG27[35]); $topic_templates->set_var('lang_hidden_info', $LANG27[36]); if ($A['hidden'] == 1) { $topic_templates->set_var('hidden_checked', 'checked="checked"'); } else { $topic_templates->set_var('hidden_checked', ''); } $topic_templates->set_var('lang_donotusespaces', $LANG27[5]); $topic_templates->set_var('lang_accessrights', $LANG_ACCESS['accessrights']); $topic_templates->set_var('lang_owner', $LANG_ACCESS['owner']); $ownername = COM_getDisplayName($A['owner_id']); $topic_templates->set_var('owner_username', DB_getItem($_TABLES['users'], 'username', "uid = {$A['owner_id']}")); $topic_templates->set_var('owner_name', $ownername); $topic_templates->set_var('owner', $ownername); $topic_templates->set_var('owner_id', $A['owner_id']); $topic_templates->set_var('lang_group', $LANG_ACCESS['group']); $topic_templates->set_var('lang_save', $LANG_ADMIN['save']); $topic_templates->set_var('lang_cancel', $LANG_ADMIN['cancel']); $topic_templates->set_var('group_dropdown', SEC_getGroupDropdown($A['group_id'], $access)); $topic_templates->set_var('lang_permissions', $LANG_ACCESS['permissions']); $topic_templates->set_var('lang_permissions_key', $LANG_ACCESS['permissionskey']); $topic_templates->set_var('lang_perm_key', $LANG_ACCESS['permissionskey']); $topic_templates->set_var('permissions_msg', $LANG_ACCESS['permmsg']); $topic_templates->set_var('lang_permissions_msg', $LANG_ACCESS['permmsg']); $topic_templates->set_var('permissions_editor', SEC_getPermissionsHTML($A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon'])); // show sort order only if they specified sortnum as the sort method if ($_CONF['sortmethod'] !== 'alpha') { $topic_templates->set_var('lang_sortorder', $LANG27[10]); if ($A['sortnum'] == 0) { $A['sortnum'] = ''; } $topic_templates->set_var('sort_order', '<input type="text" size="5" maxlength="5" name="sortnum" value="' . $A['sortnum'] . '"' . XHTML . '>'); } else { $topic_templates->set_var('lang_sortorder', $LANG27[14]); $topic_templates->set_var('sort_order', $LANG27[15] . '<input type="hidden" name="sortnum" value="' . $A['sortnum'] . '"' . XHTML . '>'); } $topic_templates->set_var('lang_storiesperpage', $LANG27[11]); if ($A['limitnews'] == 0) { $topic_templates->set_var('story_limit', ''); } else { $topic_templates->set_var('story_limit', $A['limitnews']); } $topic_templates->set_var('default_limit', $_CONF['limitnews']); $topic_templates->set_var('lang_defaultis', $LANG27[16]); $topic_templates->set_var('lang_topicname', $LANG27[3]); $topic_templates->set_var('topic_name', htmlspecialchars(stripslashes($A['topic']), ENT_QUOTES, COM_getEncodingt())); if (empty($A['tid'])) { $A['imageurl'] = '/images/topics/'; } $topic_templates->set_var('lang_topicimage', $LANG27[4]); $topic_templates->set_var('lang_uploadimage', $LANG27[27]); $topic_templates->set_var('lang_maxsize', $LANG27[28]); $topic_templates->set_var('icon_dimensions', $_CONF['max_topicicon_width'] . ' x ' . $_CONF['max_topicicon_height']); $topic_templates->set_var('max_url_length', 255); $topic_templates->set_var('image_url', $A['imageurl']); if (empty($_CONF['image_lib'])) { $scaling = $LANG04[162]; } else { $scaling = $LANG04[161]; } $topic_templates->set_var('icon_max_dimensions', sprintf($LANG04[160], $_CONF['max_topicicon_width'], $_CONF['max_topicicon_height'], $_CONF['max_topicicon_size'], $scaling)); $topic_templates->set_var('lang_metadescription', $LANG_ADMIN['meta_description']); $topic_templates->set_var('lang_metakeywords', $LANG_ADMIN['meta_keywords']); if (!empty($A['meta_description'])) { $topic_templates->set_var('meta_description', $A['meta_description']); } if (!empty($A['meta_keywords'])) { $topic_templates->set_var('meta_keywords', $A['meta_keywords']); } if ($_CONF['meta_tags'] > 0) { $topic_templates->set_var('hide_meta', ''); } else { $topic_templates->set_var('hide_meta', ' style="display:none;"'); } $topic_templates->set_var('lang_defaulttopic', $LANG27[22]); $topic_templates->set_var('lang_defaulttext', $LANG27[23]); if ($A['is_default'] == 1) { $topic_templates->set_var('default_checked', 'checked="checked"'); } else { $topic_templates->set_var('default_checked', ''); } $topic_templates->set_var('lang_archivetopic', $LANG27[25]); $topic_templates->set_var('lang_archivetext', $LANG27[26]); $topic_templates->set_var('archive_disabled', ''); if ($A['archive_flag'] == 1) { $topic_templates->set_var('archive_checked', 'checked="checked"'); } else { $topic_templates->set_var('archive_checked', ''); // Only 1 topic can be the archive topic - so check if there already is one if (DB_count($_TABLES['topics'], 'archive_flag', '1') > 0) { $topic_templates->set_var('archive_disabled', 'disabled'); } } if (empty($tid)) { $num_stories = $LANG_ADMIN['na']; } else { $nResult = DB_query("SELECT COUNT(*) AS count FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta WHERE ta.type = 'article' AND ta.id = sid AND ta.tid = '" . DB_escapeString($tid) . "'" . COM_getPermSql('AND')); $N = DB_fetchArray($nResult); $num_stories = COM_numberFormat($N['count']); } $topic_templates->set_var('lang_num_stories', $LANG27[30]); $topic_templates->set_var('num_stories', $num_stories); $topic_templates->set_var('gltoken_name', CSRF_TOKEN); $topic_templates->set_var('gltoken', $token); $topic_templates->parse('output', 'editor'); $retval .= $topic_templates->finish($topic_templates->get_var('output')); $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')); return $retval; }
function MG_mediaEdit($album_id, $media_id, $actionURL = '', $mqueue = 0, $view = 0, $back = '') { global $_USER, $_CONF, $_MG_CONF, $_TABLES, $_MG_CONF, $LANG_MG00, $LANG_MG01, $LANG_MG03, $LANG_MG07, $_DB_dbms; $album = new mgAlbum($album_id); if ($actionURL == '') { $actionURL = $_MG_CONF['site_url'] . '/index.php'; } $retval = ''; $T = COM_newTemplate(MG_getTemplatePath($album_id)); $T->set_file(array('admin' => 'mediaedit.thtml', 'asf_options' => 'edit_asf_options.thtml', 'mp3_options' => 'edit_mp3_options.thtml', 'swf_options' => 'edit_swf_options.thtml', 'mov_options' => 'edit_mov_options.thtml', 'flv_options' => 'edit_flv_options.thtml')); // pull the media information from the database... $sql = "SELECT * FROM "; if ($_DB_dbms == "mssql") { $sql = "SELECT *,CAST(media_desc AS TEXT) AS media_desc FROM "; } $sql .= ($mqueue ? $_TABLES['mg_mediaqueue'] : $_TABLES['mg_media']) . " WHERE media_id='" . addslashes($media_id) . "'"; $result = DB_query($sql); $row = DB_fetchArray($result); if ($album->access != 3 && !SEC_inGroup($album->mod_group_id) && $row['media_user_id'] != $_USER['uid']) { COM_errorLog("Someone has tried to illegally sort albums in Media Gallery. " . "User id: {$_USER['uid']}, Username: {$_USER['username']}, IP: {$REMOTE_ADDR}", 1); return COM_showMessageText($LANG_MG00['access_denied_msg']); } // Build Album List $album_jumpbox = '<select name="albums" width="40">'; $root_album = new mgAlbum(0); $root_album->buildJumpBox($album_jumpbox, $album_id); $album_jumpbox .= '</select>'; // should check the above for errors, etc... $exif_info = ''; if ($row['media_type'] == 0) { if (!function_exists('MG_readEXIF')) { require_once $_CONF['path'] . 'plugins/mediagallery/include/lib-exif.php'; } $exif_info = MG_readEXIF($row['media_id'], 1, $mqueue); if (empty($exif_info)) { $exif_info = ''; } } $media_time_month = date("m", $row['media_time']); $media_time_day = date("d", $row['media_time']); $media_time_year = date("Y", $row['media_time']); $media_time_hour = date("H", $row['media_time']); $media_time_minute = date("i", $row['media_time']); $month_select = '<select name="media_month">'; $month_select .= COM_getMonthFormOptions($media_time_month); $month_select .= '</select>'; $day_select = '<select name="media_day">'; for ($i = 1; $i < 32; $i++) { $day_select .= '<option value="' . $i . '"' . ($media_time_day == $i ? 'selected="selected"' : "") . '>' . $i . '</option>'; } $day_select .= '</select>'; $current_year = (int) date("Y"); $end_year = $current_year + 10; $year_select = '<select name="media_year">'; for ($i = 1998; $i < $end_year; $i++) { $year_select .= '<option value="' . $i . '"' . ($media_time_year == $i ? 'selected="selected"' : "") . '>' . $i . '</option>'; } $year_select .= '</select>'; $hour_select = '<select name="media_hour">'; for ($i = 0; $i < 24; $i++) { $hour_select .= '<option value="' . $i . '"' . ($media_time_hour == $i ? 'selected="selected"' : "") . '>' . $i . '</option>'; } $hour_select .= '</select>'; $minute_select = '<select name="media_minute">'; for ($i = 0; $i < 60; $i++) { $minute_select .= '<option value="' . $i . '"' . ($media_time_minute == $i ? 'selected="selected"' : "") . '>' . ($i < 10 ? '0' : '') . $i . '</option>'; } $minute_select .= '</select>'; $media_time = MG_getUserDateTimeFormat($row['media_time']); $tn_size = 1; list($thumbnail, $pThumbnail, $size) = Media::getThumbInfo($row, $tn_size); $attached_thumbnail = ''; if ($row['media_tn_attached'] == 1) { $atnsize = ''; if ($size != false) { list($newwidth, $newheight) = Media::getImageWH($size[0], $size[1], 150, 150); $atnsize = 'width="' . $newwidth . '" height="' . $newheight . '"'; } $attached_thumbnail = '<img src="' . $thumbnail . '" alt="" ' . $atnsize . XHTML . '>'; $tmpthumb = Media::getDefaultThumbnail($row, $tn_size); $thumbnail = $_MG_CONF['mediaobjects_url'] . '/' . $tmpthumb; $size = getimagesize($_MG_CONF['path_mediaobjects'] . $tmpthumb); } $preview = ''; $preview_end = ''; if ($row['media_type'] == 0 || $row['media_type'] == 1 || $row['media_type'] == 2) { // image, video and music file if ($row['media_type'] == 2) { $win_width = 540; $win_height = 320; } elseif ($row['media_type'] == 1) { $win_width = 660; $win_height = 525; } elseif ($row['media_type'] == 0) { $path = Media::getFilePath('disp', $row['media_filename'], $row['media_mime_ext']); $media_size_disp = @getimagesize($path); $win_width = $media_size_disp[0] + 20; $win_height = $media_size_disp[1] + 20; } else { $win_width = 800; $win_height = 600; } $url = Media::getHref_showvideo($row['media_id'], $win_height, $win_width, $mqueue); $preview = "<a href=\"" . $url . "\">"; $preview_end = "</a>"; } $rotate_right = ''; $rotate_left = ''; if ($row['media_type'] == 0 && ($_CONF['image_lib'] != 'gdlib' || function_exists("imagerotate"))) { $rotate_right = '<a href="' . $_MG_CONF['site_url'] . '/admin.php?mode=rotate&action=right&media_id=' . $row['media_id'] . '&album_id=' . $album_id . '">' . '<img src="' . $_MG_CONF['site_url'] . '/images/rotate_right_icon.gif" alt="' . $LANG_MG01['rotate_left'] . '" style="border:none;"' . XHTML . '></a>'; $rotate_left = '<a href="' . $_MG_CONF['site_url'] . '/admin.php?mode=rotate&action=left&media_id=' . $row['media_id'] . '&album_id=' . $album_id . '">' . '<img src="' . $_MG_CONF['site_url'] . '/images/rotate_left_icon.gif" alt="' . $LANG_MG01['rotate_right'] . '" style="border:none;"' . XHTML . '></a>'; } $resolution = ''; $lang_resolution = ''; if ($row['media_type'] == 1) { // video file $resolution = 'unknown'; if ($row['media_resolution_x'] > 0 && $row['media_resolution_y'] > 0) { $resolution = $row['media_resolution_x'] . 'x' . $row['media_resolution_y']; } $lang_resolution = $LANG_MG07['resolution']; } $sql = "SELECT * FROM {$_TABLES['mg_playback_options']} " . "WHERE media_id='" . addslashes($row['media_id']) . "'"; $poResult = DB_query($sql); $poNumRows = DB_numRows($poResult); // playback options, if needed... if ($row['mime_type'] == 'video/x-ms-asf' || $row['mime_type'] == 'video/x-ms-wvx' || $row['mime_type'] == 'video/x-ms-wm' || $row['mime_type'] == 'video/x-ms-wmx' || $row['mime_type'] == 'video/x-ms-wmv' || $row['mime_type'] == 'audio/x-ms-wma' || $row['mime_type'] == 'video/x-msvideo') { // pull defaults, then override... $playback_options['autostart'] = $_MG_CONF['asf_autostart']; $playback_options['enablecontextmenu'] = $_MG_CONF['asf_enablecontextmenu']; $playback_options['stretchtofit'] = $_MG_CONF['asf_stretchtofit']; $playback_options['uimode'] = $_MG_CONF['asf_uimode']; $playback_options['showstatusbar'] = $_MG_CONF['asf_showstatusbar']; $playback_options['playcount'] = $_MG_CONF['asf_playcount']; $playback_options['height'] = $_MG_CONF['asf_height']; $playback_options['width'] = $_MG_CONF['asf_width']; $playback_options['bgcolor'] = $_MG_CONF['asf_bgcolor']; for ($i = 0; $i < $poNumRows; $i++) { $poRow = DB_fetchArray($poResult); $playback_options[$poRow['option_name']] = $poRow['option_value']; } $uimode_select = MG_optionlist(array('name' => 'uimode', 'current' => $playback_options['uimode'], 'values' => array('none' => $LANG_MG07['none'], 'mini' => $LANG_MG07['mini'], 'full' => $LANG_MG07['full']))); $T->set_var(array('autostart_enabled' => $playback_options['autostart'] ? ' checked="checked"' : '', 'autostart_disabled' => $playback_options['autostart'] ? '' : ' checked="checked"', 'enablecontextmenu_enabled' => $playback_options['enablecontextmenu'] ? ' checked="checked"' : '', 'enablecontextmenu_disabled' => $playback_options['enablecontextmenu'] ? '' : ' checked="checked"', 'stretchtofit_enabled' => $playback_options['stretchtofit'] ? ' checked="checked"' : '', 'stretchtofit_disabled' => $playback_options['stretchtofit'] ? '' : ' checked="checked"', 'showstatusbar_enabled' => $playback_options['showstatusbar'] ? ' checked="checked"' : '', 'showstatusbar_disabled' => $playback_options['showstatusbar'] ? '' : ' checked="checked"', 'uimode_select' => $uimode_select, 'uimode' => $playback_options['uimode'], 'playcount' => $playback_options['playcount'], 'height' => $playback_options['height'], 'width' => $playback_options['width'], 'bgcolor' => $playback_options['bgcolor'], 'lang_resolution' => $lang_resolution, 'resolution' => $resolution)); $T->parse('playback_options', 'asf_options'); } if ($row['mime_type'] == 'audio/mpeg') { // pull defaults, then override... $playback_options['autostart'] = $_MG_CONF['mp3_autostart']; $playback_options['enablecontextmenu'] = $_MG_CONF['mp3_enablecontextmenu']; $playback_options['uimode'] = $_MG_CONF['mp3_uimode']; $playback_options['showstatusbar'] = $_MG_CONF['mp3_showstatusbar']; $playback_options['loop'] = $_MG_CONF['mp3_loop']; for ($i = 0; $i < $poNumRows; $i++) { $poRow = DB_fetchArray($poResult); $playback_options[$poRow['option_name']] = $poRow['option_value']; } $uimode_select = MG_optionlist(array('name' => 'uimode', 'current' => $playback_options['uimode'], 'values' => array('none' => $LANG_MG07['none'], 'mini' => $LANG_MG07['mini'], 'full' => $LANG_MG07['full']))); $T->set_var(array('autostart_enabled' => $playback_options['autostart'] ? ' checked="checked"' : '', 'autostart_disabled' => $playback_options['autostart'] ? '' : ' checked="checked"', 'enablecontextmenu_enabled' => $playback_options['enablecontextmenu'] ? ' checked="checked"' : '', 'enablecontextmenu_disabled' => $playback_options['enablecontextmenu'] ? '' : ' checked="checked"', 'showstatusbar_enabled' => $playback_options['showstatusbar'] ? ' checked="checked"' : '', 'showstatusbar_disabled' => $playback_options['showstatusbar'] ? '' : ' checked="checked"', 'loop_enabled' => $playback_options['loop'] ? ' checked="checked"' : '', 'loop_disabled' => $playback_options['loop'] ? '' : ' checked="checked"', 'uimode_select' => $uimode_select, 'uimode' => $playback_options['uimode'])); $T->parse('playback_options', 'mp3_options'); } if ($row['mime_type'] == 'application/x-shockwave-flash' || $row['mime_type'] == 'video/x-flv') { // pull defaults, then override... $playback_options['play'] = $_MG_CONF['swf_play']; $playback_options['menu'] = $_MG_CONF['swf_menu']; $playback_options['quality'] = $_MG_CONF['swf_quality']; $playback_options['height'] = $_MG_CONF['swf_height']; $playback_options['width'] = $_MG_CONF['swf_width']; $playback_options['loop'] = $_MG_CONF['swf_loop']; $playback_options['scale'] = $_MG_CONF['swf_scale']; $playback_options['wmode'] = $_MG_CONF['swf_wmode']; $playback_options['allowscriptaccess'] = $_MG_CONF['swf_allowscriptaccess']; $playback_options['bgcolor'] = $_MG_CONF['swf_bgcolor']; $playback_options['swf_version'] = $_MG_CONF['swf_version']; for ($i = 0; $i < $poNumRows; $i++) { $poRow = DB_fetchArray($poResult); $playback_options[$poRow['option_name']] = $poRow['option_value']; } $quality_select = MG_optionlist(array('name' => 'quality', 'current' => $playback_options['quality'], 'values' => array('low' => $LANG_MG07['low'], 'high' => $LANG_MG07['high']))); $scale_select = MG_optionlist(array('name' => 'scale', 'current' => $playback_options['scale'], 'values' => array('showall' => $LANG_MG07['showall'], 'noborder' => $LANG_MG07['noborder'], 'exactfit' => $LANG_MG07['exactfit']))); $wmode_select = MG_optionlist(array('name' => 'wmode', 'current' => $playback_options['wmode'], 'values' => array('window' => $LANG_MG07['window'], 'opaque' => $LANG_MG07['opaque'], 'transparent' => $LANG_MG07['transparent']))); $asa_select = MG_optionlist(array('name' => 'allowscriptaccess', 'current' => $playback_options['allowscriptaccess'], 'values' => array('always' => $LANG_MG07['always'], 'sameDomain' => $LANG_MG07['sameDomain'], 'never' => $LANG_MG07['never']))); $T->set_var(array('play_enabled' => $playback_options['play'] ? ' checked="checked"' : '', 'play_disabled' => $playback_options['play'] ? '' : ' checked="checked"', 'menu_enabled' => $playback_options['menu'] ? ' checked="checked"' : '', 'menu_disabled' => $playback_options['menu'] ? '' : ' checked="checked"', 'loop_enabled' => $playback_options['loop'] ? ' checked="checked"' : '', 'loop_disabled' => $playback_options['loop'] ? '' : ' checked="checked"', 'quality_select' => $quality_select, 'scale_select' => $scale_select, 'wmode_select' => $wmode_select, 'asa_select' => $asa_select, 'flashvars' => isset($playback_options['flashvars']) ? $playback_options['flashvars'] : '', 'height' => $playback_options['height'], 'width' => $playback_options['width'], 'bgcolor' => $playback_options['bgcolor'], 'swf_version' => $playback_options['swf_version'])); if ($row['mime_type'] == 'application/x-shockwave-flash') { $T->parse('playback_options', 'swf_options'); } else { $T->parse('playback_options', 'flv_options'); } } if ($row['media_mime_ext'] == 'mov' || $row['media_mime_ext'] == 'mp4' || $row['mime_type'] == 'video/quicktime' || $row['mime_type'] == 'video/mpeg') { // pull defaults, then override... $playback_options['autoref'] = $_MG_CONF['mov_autoref']; $playback_options['autoplay'] = $_MG_CONF['mov_autoplay']; $playback_options['controller'] = $_MG_CONF['mov_controller']; $playback_options['kioskmode'] = isset($_MG_CONF['mov_kioskmod']) ? $_MG_CONF['mov_kiokmode'] : ''; $playback_options['scale'] = $_MG_CONF['mov_scale']; $playback_options['loop'] = $_MG_CONF['mov_loop']; $playback_options['height'] = $_MG_CONF['mov_height']; $playback_options['width'] = $_MG_CONF['mov_width']; $playback_options['bgcolor'] = $_MG_CONF['mov_bgcolor']; for ($i = 0; $i < $poNumRows; $i++) { $poRow = DB_fetchArray($poResult); $playback_options[$poRow['option_name']] = $poRow['option_value']; } $scale_select = MG_optionlist(array('name' => 'scale', 'current' => $playback_options['scale'], 'values' => array('tofit' => $LANG_MG07['to_fit'], 'aspect' => $LANG_MG07['aspect'], '1' => $LANG_MG07['normal_size']))); $T->set_var(array('autoref_enabled' => $playback_options['autoref'] ? ' checked="checked"' : '', 'autoref_disabled' => $playback_options['autoref'] ? '' : ' checked="checked"', 'autoplay_enabled' => $playback_options['autoplay'] ? ' checked="checked"' : '', 'autoplay_disabled' => $playback_options['autoplay'] ? '' : ' checked="checked"', 'controller_enabled' => $playback_options['controller'] ? ' checked="checked"' : '', 'controller_disabled' => $playback_options['controller'] ? '' : ' checked="checked"', 'kioskmode_enabled' => $playback_options['kioskmode'] ? ' checked="checked"' : '', 'kioskmode_disabled' => $playback_options['kioskmode'] ? '' : ' checked="checked"', 'loop_enabled' => $playback_options['loop'] ? ' checked="checked"' : '', 'loop_disabled' => $playback_options['loop'] ? '' : ' checked="checked"', 'height' => $playback_options['height'], 'width' => $playback_options['width'], 'bgcolor' => $playback_options['bgcolor'])); $T->parse('playback_options', 'mov_options'); } $remoteurl = $row['remote_url']; $lang_remote_url = $row['remote_media'] == 1 ? $LANG_MG01['remote_url'] : $LANG_MG01['alternate_url']; // user information $username = ''; if (SEC_hasRights('mediagallery.admin')) { $username = '******'; $sql = "SELECT * FROM {$_TABLES['users']} WHERE status=3 AND uid > 1 ORDER BY username ASC"; $result = DB_query($sql); while ($userRow = DB_fetchArray($result)) { $username .= '<option value="' . $userRow['uid'] . '"' . ($userRow['uid'] == $row['media_user_id'] ? ' selected="selected"' : '') . '>' . $userRow['username'] . '</option>' . LB; } $username .= '</select>'; } else { if ($row['media_user_id'] != '') { $displayname = $_CONF['show_fullname'] ? 'fullname' : 'username'; $username = DB_getItem($_TABLES['users'], $displayname, "uid={$row['media_user_id']}"); } } $cat_select = '<select name="cat_id" id="cat_id">'; $cat_select .= '<option value="">' . $LANG_MG01['no_category'] . '</option>'; $result = DB_query("SELECT * FROM {$_TABLES['mg_category']} ORDER BY cat_id ASC"); while ($catRow = DB_fetchArray($result)) { $cat_select .= '<option value="' . $catRow['cat_id'] . '" ' . ($catRow['cat_id'] == $row['media_category'] ? ' selected="selected"' : '') . '>' . $catRow['cat_name'] . '</option>'; } $cat_select .= '</select>'; $T->set_var(array('original_filename' => $row['media_original_filename'], 'attach_tn' => $row['media_tn_attached'], 'at_tn_checked' => $row['media_tn_attached'] == 1 ? ' checked="checked"' : '', 'attached_thumbnail' => $attached_thumbnail, 'album_id' => $album_id, 'media_thumbnail' => $thumbnail, 'media_id' => $row['media_id'], 'media_title' => $row['media_title'], 'media_desc' => $row['media_desc'], 'media_time' => $media_time[0], 'media_views' => $row['media_views'], 'media_comments' => $row['media_comments'], 'media_exif_info' => $exif_info, 'media_rating_max' => 5, 'height' => $size[1] + 50, 'width' => $size[0] + 40, 'queue' => $mqueue, 'month_select' => $month_select, 'day_select' => $day_select, 'year_select' => $year_select, 'hour_select' => $hour_select, 'minute_select' => $minute_select, 'user_ip' => $row['media_user_ip'], 'album_select' => $album_jumpbox, 'media_rating' => $row['media_rating'] / 2, 'media_votes' => $row['media_votes'], 's_mode' => 'edit', 's_title' => $LANG_MG01['edit_media'], 's_rotate_right' => $rotate_right, 's_rotate_left' => $rotate_left, 's_form_action' => $actionURL, 'allowed_html' => COM_allowedHTML(), 'site_url' => $_MG_CONF['site_url'], 'preview' => $preview, 'preview_end' => $preview_end, 'rpath' => htmlentities($back, ENT_QUOTES, COM_getCharset()), 'remoteurl' => $remoteurl, 'lang_remote_url' => $lang_remote_url, 'resolution' => $resolution, 'lang_resolution' => $lang_resolution, 'username' => $username, 'cat_select' => $cat_select, 'media_keywords' => $row['media_keywords'], 'artist' => $row['artist'], 'musicalbum' => $row['album'], 'genre' => $row['genre'])); // language items $T->set_var(array('lang_playcount' => $LANG_MG07['playcount'], 'lang_playcount_help' => $LANG_MG07['playcount_help'], 'lang_playback_options' => $LANG_MG07['playback_options'], 'lang_option' => $LANG_MG07['option'], 'lang_description' => $LANG_MG07['description'], 'lang_on' => $LANG_MG07['on'], 'lang_off' => $LANG_MG07['off'], 'lang_auto_start' => $LANG_MG07['auto_start'], 'lang_auto_start_help' => $LANG_MG07['auto_start_help'], 'lang_height' => $LANG_MG07['height'], 'lang_width' => $LANG_MG07['width'], 'lang_height_help' => $LANG_MG07['height_help'], 'lang_width_help' => $LANG_MG07['width_help'], 'lang_enable_context_menu' => $LANG_MG07['enable_context_menu'], 'lang_enable_context_menu_help' => $LANG_MG07['enable_context_menu_help'], 'lang_stretch_to_fit' => $LANG_MG07['stretch_to_fit'], 'lang_stretch_to_fit_help' => $LANG_MG07['stretch_to_fit_help'], 'lang_status_bar' => $LANG_MG07['status_bar'], 'lang_status_bar_help' => $LANG_MG07['status_bar_help'], 'lang_ui_mode' => $LANG_MG07['ui_mode'], 'lang_ui_mode_help' => $LANG_MG07['ui_mode_help'], 'lang_bgcolor' => $LANG_MG07['bgcolor'], 'lang_bgcolor_help' => $LANG_MG07['bgcolor_help'], 'lang_loop' => $LANG_MG07['loop'], 'lang_loop_help' => $LANG_MG07['loop_help'], 'lang_menu' => $LANG_MG07['menu'], 'lang_menu_help' => $LANG_MG07['menu_help'], 'lang_scale' => $LANG_MG07['scale'], 'lang_swf_scale_help' => $LANG_MG07['swf_scale_help'], 'lang_wmode' => $LANG_MG07['wmode'], 'lang_wmode_help' => $LANG_MG07['wmode_help'], 'lang_quality' => $LANG_MG07['quality'], 'lang_quality_help' => $LANG_MG07['quality_help'], 'lang_flash_vars' => $LANG_MG07['flash_vars'], 'lang_asa' => $LANG_MG07['asa'], 'lang_asa_help' => $LANG_MG07['asa_help'], 'lang_swf_version_help' => $LANG_MG07['swf_version_help'], 'lang_auto_ref' => $LANG_MG07['auto_ref'], 'lang_auto_ref_help' => $LANG_MG07['auto_ref_help'], 'lang_controller' => $LANG_MG07['controller'], 'lang_controller_help' => $LANG_MG07['controller_help'], 'lang_kiosk_mode' => $LANG_MG07['kiosk_mode'], 'lang_kiosk_mode_help' => $LANG_MG07['kiosk_mode_help'], 'lang_original_filename' => $LANG_MG01['original_filename'], 'lang_media_item' => $LANG_MG00['media_col_header'], 'lang_media_attributes' => $LANG_MG01['media_attributes'], 'lang_mediaattributes' => $LANG_MG01['mediaattributes'], 'lang_attached_thumbnail' => $LANG_MG01['attached_thumbnail'], 'lang_category' => $LANG_MG01['category'], 'lang_keywords' => $LANG_MG01['keywords'], 'lang_rating' => $LANG_MG03['rating'], 'lang_comments' => $LANG_MG03['comments'], 'lang_votes' => $LANG_MG03['votes'], 'media_edit_title' => $LANG_MG01['media_edit'], 'media_edit_help' => $LANG_MG01['media_edit_help'], 'rotate_left' => $LANG_MG01['rotate_left'], 'rotate_right' => $LANG_MG01['rotate_right'], 'lang_title' => $LANG_MG01['title'], 'albums' => $LANG_MG01['albums'], 'description' => $LANG_MG01['description'], 'capture_time' => $LANG_MG01['capture_time'], 'views' => $LANG_MG03['views'], 'uploaded_by' => $LANG_MG01['uploaded_by'], 'submit' => $LANG_MG01['submit'], 'cancel' => $LANG_MG01['cancel'], 'reset' => $LANG_MG01['reset'], 'lang_save' => $LANG_MG01['save'], 'lang_reset' => $LANG_MG01['reset'], 'lang_cancel' => $LANG_MG01['cancel'], 'lang_delete' => $LANG_MG01['delete'], 'lang_delete_confirm' => $LANG_MG01['delete_item_confirm'], 'lang_reset_rating' => $LANG_MG01['reset_rating'], 'lang_reset_views' => $LANG_MG01['reset_views'], 'lang_replacefile' => $LANG_MG01['replace_file'], 'lang_artist' => $LANG_MG01['artist'], 'lang_genre' => $LANG_MG01['genre'], 'lang_music_album' => $LANG_MG01['music_album'])); $retval .= $T->finish($T->parse('output', 'admin')); return $retval; }
/** * Main Form used for Custom membership when member is registering * * Note: Requires a file custom/memberdetail.thtml in every theme that is * installed on the site! * * @param string $msg an error message to display or the word 'new' * @return string HTML for the registration form * */ function CUSTOM_userForm($msg = '') { global $_CONF, $_TABLES, $LANG04; $retval = ''; if (!empty($msg) && $msg != 'new') { $retval .= COM_startBlock($LANG04[21]) . $msg . COM_endBlock(); } $post_url = $_CONF['site_url'] . '/users.php'; $postmode = 'create'; $submitbutton = '<input type="submit" value="Register Now!"' . XHTML . '>'; $message = "<blockquote style=\"padding-top:10px;\"><b>Please complete the application below. Once you have completed the application, click the Register Now! button and the application will be processed immediately.</b></blockquote>"; $user_templates = COM_newTemplate($_CONF['path_layout'] . 'custom'); $user_templates->set_file('memberdetail', 'memberdetail.thtml'); $user_templates->set_var('post_url', $post_url); $user_templates->set_var('startblock', COM_startBlock("Custom Registration Example")); $user_templates->set_var('message', $message); $user_templates->set_var('USERNAME', $LANG04[2]); $user_templates->set_var('USERNAME_HELP', "Name to be used when accessing this site"); $username = ''; if (isset($_POST['username'])) { $username = COM_applyFilter($_POST['username']); } $user_templates->set_var('username', $username); $user_templates->set_var('EMAIL', $LANG04[5]); $user_templates->set_var('EMAIL_HELP', $LANG04[33]); $email = ''; if (isset($_POST['email'])) { $email = COM_applyFilter($_POST['email']); } $user_templates->set_var('email', $email); $user_templates->set_var('EMAIL_CONF', $LANG04[124]); $user_templates->set_var('EMAIL_CONF_HELP', $LANG04[126]); $email_conf = ''; if (isset($_POST['email_conf'])) { $email_conf = COM_applyFilter($_POST['email_conf']); } $user_templates->set_var('email_conf', $email_conf); $user_templates->set_var('FULLNAME', $LANG04[3]); $user_templates->set_var('FULLNAME_HELP', $LANG04[34]); $fullname = ''; if (isset($_POST['fullname'])) { $fullname = strip_tags($_POST['fullname']); } $user_templates->set_var('fullname', $fullname); $user_templates->set_var('user_id', $user); $user_templates->set_var('postmode', $postmode); $user_templates->set_var('submitbutton', $submitbutton); $user_templates->set_var('endblock', COM_endBlock()); $user_templates->parse('output', 'memberdetail'); $retval .= $user_templates->finish($user_templates->get_var('output')); return $retval; }
/** * Shows story editor * * Displays the story entry form * * @param string $sid ID of story to edit * @param string $mode 'preview', 'edit', 'editsubmission', 'clone' * @param string $errormsg a message to display on top of the page * @return string HTML for story editor * */ function storyeditor($sid = '', $mode = '', $errormsg = '') { global $_CONF, $_TABLES, $_USER, $LANG24, $LANG_ACCESS, $LANG_ADMIN, $MESSAGE, $_SCRIPTS, $LANG_DIRECTION, $LANG_MONTH, $LANG_WEEK; $display = ''; if (!isset($_CONF['hour_mode'])) { $_CONF['hour_mode'] = 12; } if (!empty($errormsg)) { $display .= COM_showMessageText($errormsg, $LANG24[25]); } $story = new Story(); if ($mode == 'preview') { // Handle Magic GPC Garbage: while (list($key, $value) = each($_POST)) { if (!is_array($value)) { $_POST[$key] = COM_stripslashes($value); } else { while (list($subkey, $subvalue) = each($value)) { $value[$subkey] = COM_stripslashes($subvalue); } } } $result = $story->loadFromArgsArray($_POST); if ($_CONF['maximagesperarticle'] > 0) { $errors = $story->checkAttachedImages(); if (count($errors) > 0) { $msg = $LANG24[55] . LB . '<ul>' . LB; foreach ($errors as $err) { $msg .= '<li>' . $err . '</li>' . LB; } $msg .= '</ul>' . LB; $display .= COM_showMessageText($msg, $LANG24[54]); } } } else { $result = $story->loadFromDatabase($sid, $mode); } if ($result == STORY_PERMISSION_DENIED || $result == STORY_NO_ACCESS_PARAMS) { $display .= COM_showMessageText($LANG24[42], $LANG_ACCESS['accessdenied']); COM_accessLog("User {$_USER['username']} tried to illegally access story {$sid}."); return $display; } elseif ($result == STORY_EDIT_DENIED || $result == STORY_EXISTING_NO_EDIT_PERMISSION) { $display .= COM_showMessageText($LANG24[41], $LANG_ACCESS['accessdenied']); $display .= STORY_renderArticle($story, 'p'); COM_accessLog("User {$_USER['username']} tried to illegally edit story {$sid}."); return $display; } elseif ($result == STORY_INVALID_SID) { if ($mode == 'editsubmission') { // that submission doesn't seem to be there any more (may have been // handled by another Admin) - take us back to the moderation page return COM_refresh($_CONF['site_admin_url'] . '/moderation.php'); } else { return COM_refresh($_CONF['site_admin_url'] . '/story.php'); } } elseif ($result == STORY_DUPLICATE_SID) { $display .= COM_showMessageText($LANG24[24]); } // Load HTML templates $story_templates = COM_newTemplate($_CONF['path_layout'] . 'admin/story'); if ($_CONF['advanced_editor'] && $_USER['advanced_editor']) { $story_templates->set_file(array('editor' => 'storyeditor_advanced.thtml')); $advanced_editormode = true; $story_templates->set_var('change_editormode', 'onchange="change_editmode(this);"'); require_once $_CONF['path_system'] . 'classes/navbar.class.php'; $story_templates->set_var('show_preview', 'none'); $story_templates->set_var('lang_expandhelp', $LANG24[67]); $story_templates->set_var('lang_reducehelp', $LANG24[68]); $story_templates->set_var('lang_publishdate', $LANG24[69]); $story_templates->set_var('lang_toolbar', $LANG24[70]); $story_templates->set_var('toolbar1', $LANG24[71]); $story_templates->set_var('toolbar2', $LANG24[72]); $story_templates->set_var('toolbar3', $LANG24[73]); $story_templates->set_var('toolbar4', $LANG24[74]); $story_templates->set_var('toolbar5', $LANG24[75]); if ($story->EditElements('advanced_editor_mode') == 1 or $story->EditElements('postmode') == 'adveditor') { $story_templates->set_var('show_texteditor', 'none'); $story_templates->set_var('show_htmleditor', ''); } else { $story_templates->set_var('show_texteditor', ''); $story_templates->set_var('show_htmleditor', 'none'); } } else { $story_templates->set_file(array('editor' => 'storyeditor.thtml')); $advanced_editormode = false; } $story_templates->set_var('hour_mode', $_CONF['hour_mode']); if ($story->hasContent()) { $previewContent = STORY_renderArticle($story, 'p'); if ($advanced_editormode and $previewContent != '') { $story_templates->set_var('preview_content', $previewContent); } elseif ($previewContent != '') { $display .= COM_startBlock($LANG24[26], '', COM_getBlockTemplate('_admin_block', 'header')); $display .= $previewContent; $display .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')); } } if ($advanced_editormode) { $navbar = new navbar(); if (!empty($previewContent)) { $navbar->add_menuitem($LANG24[79], 'showhideEditorDiv("preview",0);return false;', true); $navbar->add_menuitem($LANG24[80], 'showhideEditorDiv("editor",1);return false;', true); $navbar->add_menuitem($LANG24[81], 'showhideEditorDiv("publish",2);return false;', true); $navbar->add_menuitem($LANG24[82], 'showhideEditorDiv("images",3);return false;', true); $navbar->add_menuitem($LANG24[83], 'showhideEditorDiv("archive",4);return false;', true); $navbar->add_menuitem($LANG24[84], 'showhideEditorDiv("perms",5);return false;', true); $navbar->add_menuitem($LANG24[85], 'showhideEditorDiv("all",6);return false;', true); } else { $navbar->add_menuitem($LANG24[80], 'showhideEditorDiv("editor",0);return false;', true); $navbar->add_menuitem($LANG24[81], 'showhideEditorDiv("publish",1);return false;', true); $navbar->add_menuitem($LANG24[82], 'showhideEditorDiv("images",2);return false;', true); $navbar->add_menuitem($LANG24[83], 'showhideEditorDiv("archive",3);return false;', true); $navbar->add_menuitem($LANG24[84], 'showhideEditorDiv("perms",4);return false;', true); $navbar->add_menuitem($LANG24[85], 'showhideEditorDiv("all",5);return false;', true); } if ($mode == 'preview') { $story_templates->set_var('show_preview', ''); $story_templates->set_var('show_htmleditor', 'none'); $story_templates->set_var('show_texteditor', 'none'); $story_templates->set_var('show_submitoptions', 'none'); $navbar->set_selected($LANG24[79]); } else { $navbar->set_selected($LANG24[80]); } $story_templates->set_var('navbar', $navbar->generate()); } $oldsid = $story->EditElements('originalSid'); if (!empty($oldsid) && $mode != 'clone') { $delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="mode"%s' . XHTML . '>'; $jsconfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"'; $story_templates->set_var('delete_option', sprintf($delbutton, $jsconfirm)); $story_templates->set_var('delete_option_no_confirmation', sprintf($delbutton, '')); } if ($mode == 'editsubmission' || $story->type == 'submission') { $story_templates->set_var('submission_option', '<input type="hidden" name="type" value="submission"' . XHTML . '>'); } $story_templates->set_var('lang_author', $LANG24[7]); $storyauthor = COM_getDisplayName($story->EditElements('uid')); $story_templates->set_var('story_author', $storyauthor); $story_templates->set_var('author', $storyauthor); $story_templates->set_var('story_uid', $story->EditElements('uid')); // user access info $story_templates->set_var('lang_accessrights', $LANG_ACCESS['accessrights']); $story_templates->set_var('lang_owner', $LANG_ACCESS['owner']); $ownername = COM_getDisplayName($story->EditElements('owner_id')); $story_templates->set_var('owner_username', DB_getItem($_TABLES['users'], 'username', 'uid = ' . $story->EditElements('owner_id'))); $story_templates->set_var('owner_name', $ownername); $story_templates->set_var('owner', $ownername); $story_templates->set_var('owner_id', $story->EditElements('owner_id')); $story_templates->set_var('lang_group', $LANG_ACCESS['group']); $story_templates->set_var('group_dropdown', SEC_getGroupDropdown($story->EditElements('group_id'), 3)); $story_templates->set_var('lang_permissions', $LANG_ACCESS['permissions']); $story_templates->set_var('lang_perm_key', $LANG_ACCESS['permissionskey']); $story_templates->set_var('permissions_editor', SEC_getPermissionsHTML($story->EditElements('perm_owner'), $story->EditElements('perm_group'), $story->EditElements('perm_members'), $story->EditElements('perm_anon'))); $story_templates->set_var('permissions_msg', $LANG_ACCESS['permmsg']); $story_templates->set_var('lang_permissions_msg', $LANG_ACCESS['permmsg']); $curtime = COM_getUserDateTimeFormat($story->EditElements('date')); $story_templates->set_var('lang_date', $LANG24[15]); $story_templates->set_var('publish_second', $story->EditElements('publish_second')); $publish_ampm = ''; $publish_hour = $story->EditElements('publish_hour'); if ($publish_hour >= 12) { if ($publish_hour > 12) { $publish_hour = $publish_hour - 12; } $ampm = 'pm'; } else { $ampm = 'am'; } $ampm_select = COM_getAmPmFormSelection('publish_ampm', $ampm); $story_templates->set_var('publishampm_selection', $ampm_select); $month_options = COM_getMonthFormOptions($story->EditElements('publish_month')); $story_templates->set_var('publish_month_options', $month_options); $day_options = COM_getDayFormOptions($story->EditElements('publish_day')); $story_templates->set_var('publish_day_options', $day_options); $year_options = COM_getYearFormOptions($story->EditElements('publish_year')); $story_templates->set_var('publish_year_options', $year_options); if ($_CONF['hour_mode'] == 24) { $hour_options = COM_getHourFormOptions($story->EditElements('publish_hour'), 24); } else { $hour_options = COM_getHourFormOptions($publish_hour); } $story_templates->set_var('publish_hour_options', $hour_options); $minute_options = COM_getMinuteFormOptions($story->EditElements('publish_minute')); $story_templates->set_var('publish_minute_options', $minute_options); $story_templates->set_var('publish_date_explanation', $LANG24[46]); $story_templates->set_var('story_unixstamp', $story->EditElements('unixdate')); $story_templates->set_var('expire_second', $story->EditElements('expire_second')); $expire_ampm = ''; $expire_hour = $story->EditElements('expire_hour'); if ($expire_hour >= 12) { if ($expire_hour > 12) { $expire_hour = $expire_hour - 12; } $ampm = 'pm'; } else { $ampm = 'am'; } $ampm_select = COM_getAmPmFormSelection('expire_ampm', $ampm); if (empty($ampm_select)) { // have a hidden field to 24 hour mode to prevent JavaScript errors $ampm_select = '<input type="hidden" name="expire_ampm" value=""' . XHTML . '>'; } $story_templates->set_var('expireampm_selection', $ampm_select); $month_options = COM_getMonthFormOptions($story->EditElements('expire_month')); $story_templates->set_var('expire_month_options', $month_options); $day_options = COM_getDayFormOptions($story->EditElements('expire_day')); $story_templates->set_var('expire_day_options', $day_options); $year_options = COM_getYearFormOptions($story->EditElements('expire_year')); $story_templates->set_var('expire_year_options', $year_options); if ($_CONF['hour_mode'] == 24) { $hour_options = COM_getHourFormOptions($story->EditElements('expire_hour'), 24); } else { $hour_options = COM_getHourFormOptions($expire_hour); } $story_templates->set_var('expire_hour_options', $hour_options); $minute_options = COM_getMinuteFormOptions($story->EditElements('expire_minute')); $story_templates->set_var('expire_minute_options', $minute_options); $story_templates->set_var('expire_date_explanation', $LANG24[46]); $story_templates->set_var('story_unixstamp', $story->EditElements('expirestamp')); $atopic = DB_getItem($_TABLES['topics'], 'tid', "archive_flag = 1"); $have_archive_topic = empty($atopic) ? false : true; if ($story->EditElements('statuscode') == STORY_ARCHIVE_ON_EXPIRE) { $story_templates->set_var('is_checked2', 'checked="checked"'); $story_templates->set_var('is_checked3', 'checked="checked"'); $js_showarchivedisabled = 'false'; $have_archive_topic = true; // force display of auto archive option } elseif ($story->EditElements('statuscode') == STORY_DELETE_ON_EXPIRE) { $story_templates->set_var('is_checked2', 'checked="checked"'); $story_templates->set_var('is_checked4', 'checked="checked"'); if (!$have_archive_topic) { $story_templates->set_var('is_checked3', 'style="display:none;"'); } $js_showarchivedisabled = 'false'; } else { if (!$have_archive_topic) { $story_templates->set_var('is_checked3', 'style="display:none;"'); } $js_showarchivedisabled = 'true'; } $story_templates->set_var('lang_archivetitle', $LANG24[58]); $story_templates->set_var('lang_option', $LANG24[59]); $story_templates->set_var('lang_enabled', $LANG_ADMIN['enabled']); $story_templates->set_var('lang_story_stats', $LANG24[87]); if ($have_archive_topic) { $story_templates->set_var('lang_optionarchive', $LANG24[61]); } else { $story_templates->set_var('lang_optionarchive', ''); } $story_templates->set_var('lang_optiondelete', $LANG24[62]); $story_templates->set_var('lang_title', $LANG_ADMIN['title']); $story_templates->set_var('story_title', $story->EditElements('title')); $story_templates->set_var('lang_page_title', $LANG_ADMIN['page_title']); $story_templates->set_var('page_title', $story->EditElements('page_title')); $story_templates->set_var('lang_metadescription', $LANG_ADMIN['meta_description']); $story_templates->set_var('meta_description', $story->EditElements('meta_description')); $story_templates->set_var('lang_metakeywords', $LANG_ADMIN['meta_keywords']); $story_templates->set_var('meta_keywords', $story->EditElements('meta_keywords')); if ($_CONF['meta_tags'] > 0) { $story_templates->set_var('hide_meta', ''); } else { $story_templates->set_var('hide_meta', ' style="display:none;"'); } $story_templates->set_var('lang_topic', $LANG_ADMIN['topic']); if ($mode == 'preview') { $tlist = TOPIC_getTopicSelectionControl('article', '', false, true, true); } else { $tlist = TOPIC_getTopicSelectionControl('article', $oldsid, false, true, true); } if (empty($tlist)) { $display .= COM_showMessage(101); return $display; } $story_templates->set_var('topic_selection', $tlist); $story_templates->set_var('lang_show_topic_icon', $LANG24[56]); if ($story->EditElements('show_topic_icon') == 1) { $story_templates->set_var('show_topic_icon_checked', 'checked="checked"'); } else { $story_templates->set_var('show_topic_icon_checked', ''); } $story_templates->set_var('lang_cachetime', $LANG24['cache_time']); $story_templates->set_var('lang_cachetime_desc', $LANG24['cache_time_desc']); $story_templates->set_var('cache_time', $story->EditElements('cache_time')); $story_templates->set_var('lang_draft', $LANG24[34]); if ($story->EditElements('draft_flag')) { $story_templates->set_var('is_checked', 'checked="checked"'); } $story_templates->set_var('lang_mode', $LANG24[3]); $story_templates->set_var('status_options', COM_optionList($_TABLES['statuscodes'], 'code,name', $story->EditElements('statuscode'))); $story_templates->set_var('comment_options', COM_optionList($_TABLES['commentcodes'], 'code,name', $story->EditElements('commentcode'))); $story_templates->set_var('trackback_options', COM_optionList($_TABLES['trackbackcodes'], 'code,name', $story->EditElements('trackbackcode'))); // comment expire $story_templates->set_var('lang_cmt_disable', $LANG24[63]); if ($story->EditElements('cmt_close')) { $story_templates->set_var('is_checked5', 'checked="checked"'); $js_showcmtclosedisabled = 'false'; } else { $js_showcmtclosedisabled = 'true'; } $month_options = COM_getMonthFormOptions($story->EditElements('cmt_close_month')); $story_templates->set_var('cmt_close_month_options', $month_options); $day_options = COM_getDayFormOptions($story->EditElements('cmt_close_day')); $story_templates->set_var('cmt_close_day_options', $day_options); // ensure that the year dropdown includes the close year $endtm = mktime(0, 0, 0, date('m'), date('d') + $_CONF['article_comment_close_days'], date('Y')); $yoffset = date('Y', $endtm) - date('Y'); $close_year = $story->EditElements('cmt_close_year'); if ($yoffset < -1) { $year_options = COM_getYearFormOptions($close_year, $yoffset); } elseif ($yoffset > 5) { $year_options = COM_getYearFormOptions($close_year, -1, $yoffset); } else { $year_options = COM_getYearFormOptions($close_year); } $story_templates->set_var('cmt_close_year_options', $year_options); $cmt_close_ampm = ''; $cmt_close_hour = $story->EditElements('cmt_close_hour'); //correct hour if ($cmt_close_hour >= 12) { if ($cmt_close_hour > 12) { $cmt_close_hour = $cmt_close_hour - 12; } $ampm = 'pm'; } else { $ampm = 'am'; } $ampm_select = COM_getAmPmFormSelection('cmt_close_ampm', $ampm); if (empty($ampm_select)) { // have a hidden field to 24 hour mode to prevent JavaScript errors $ampm_select = '<input type="hidden" name="cmt_close_ampm" value=""' . XHTML . '>'; } $story_templates->set_var('cmt_close_ampm_selection', $ampm_select); if ($_CONF['hour_mode'] == 24) { $hour_options = COM_getHourFormOptions($story->EditElements('cmt_close_hour'), 24); } else { $hour_options = COM_getHourFormOptions($cmt_close_hour); } $story_templates->set_var('cmt_close_hour_options', $hour_options); $minute_options = COM_getMinuteFormOptions($story->EditElements('cmt_close_minute')); $story_templates->set_var('cmt_close_minute_options', $minute_options); $story_templates->set_var('cmt_close_second', $story->EditElements('cmt_close_second')); if ($_CONF['onlyrootfeatures'] == 1 && SEC_inGroup('Root') or $_CONF['onlyrootfeatures'] !== 1) { $featured_options = "<select name=\"featured\">" . LB . COM_optionList($_TABLES['featurecodes'], 'code,name', $story->EditElements('featured')) . "</select>" . LB; } else { $featured_options = "<input type=\"hidden\" name=\"featured\" value=\"0\"" . XHTML . ">"; } $story_templates->set_var('featured_options', $featured_options); $story_templates->set_var('frontpage_options', COM_optionList($_TABLES['frontpagecodes'], 'code,name', $story->EditElements('frontpage'))); $story_templates->set_var('story_introtext', $story->EditElements('introtext')); $story_templates->set_var('story_bodytext', $story->EditElements('bodytext')); $story_templates->set_var('lang_introtext', $LANG24[16]); $story_templates->set_var('lang_bodytext', $LANG24[17]); $story_templates->set_var('lang_postmode', $LANG24[4]); $story_templates->set_var('lang_publishoptions', $LANG24[76]); $story_templates->set_var('noscript', COM_getNoScript(false, $LANG24[77], sprintf($LANG24[78], $_CONF['site_admin_url'], $sid))); $postmode = $story->EditElements('postmode'); if ($_CONF['advanced_editor'] && $_USER['advanced_editor']) { if ($story->EditElements('advanced_editor_mode') == 1 or $story->EditElements('postmode') == 'adveditor') { $postmode = ''; } } $post_options = COM_optionList($_TABLES['postmodes'], 'code,name', $postmode); $postmode_list = 'plaintext,html'; // If Advanced Mode - add post option and set default if editing story created with Advanced Editor if ($_CONF['advanced_editor'] && $_USER['advanced_editor']) { $postmode_list .= ',adveditor'; if ($story->EditElements('advanced_editor_mode') == 1 or $story->EditElements('postmode') == 'adveditor') { $post_options .= '<option value="adveditor" selected="selected">' . $LANG24[86] . '</option>'; } else { $post_options .= '<option value="adveditor">' . $LANG24[86] . '</option>'; } } if ($_CONF['wikitext_editor']) { $postmode_list .= ',wikitext'; if ($story->EditElements('postmode') == 'wikitext') { $post_options .= '<option value="wikitext" selected="selected">' . $LANG24[88] . '</option>'; } else { $post_options .= '<option value="wikitext">' . $LANG24[88] . '</option>'; } } $story_templates->set_var('post_options', $post_options); $postmode_array = explode(',', $postmode_list); $allowed_html = ''; foreach ($postmode_array as $pm) { $allowed_html .= COM_allowedHTML('story.edit', false, 1, $pm); } $allowed_tags = array('code', 'raw'); if ($_CONF['allow_page_breaks'] == 1) { $allowed_tags = array_merge($allowed_tags, array('page_break')); } $allowed_html .= COM_allowedAutotags(false, $allowed_tags); $story_templates->set_var('lang_allowed_html', $allowed_html); $fileinputs = ''; $saved_images = ''; if ($_CONF['maximagesperarticle'] > 0) { $story_templates->set_var('lang_images', $LANG24[47]); $icount = DB_count($_TABLES['article_images'], 'ai_sid', $story->getSid()); if ($icount > 0) { $result_articles = DB_query("SELECT * FROM {$_TABLES['article_images']} WHERE ai_sid = '" . $story->getSid() . "'"); for ($z = 1; $z <= $icount; $z++) { $I = DB_fetchArray($result_articles); $saved_images .= $z . ') ' . COM_createLink($I['ai_filename'], $_CONF['site_url'] . '/images/articles/' . $I['ai_filename']) . ' ' . $LANG_ADMIN['delete'] . ': <input type="checkbox" name="delete[' . $I['ai_img_num'] . ']"' . XHTML . '><br' . XHTML . '>'; } } $newallowed = $_CONF['maximagesperarticle'] - $icount; for ($z = $icount + 1; $z <= $_CONF['maximagesperarticle']; $z++) { $fileinputs .= $z . ') <input type="file" dir="ltr" name="file' . $z . '"' . XHTML . '>'; if ($z < $_CONF['maximagesperarticle']) { $fileinputs .= '<br' . XHTML . '>'; } } $fileinputs .= '<br' . XHTML . '>' . $LANG24[51]; if ($_CONF['allow_user_scaling'] == 1) { $fileinputs .= $LANG24[27]; } $fileinputs .= $LANG24[28] . '<br' . XHTML . '>'; } // Add JavaScript $_SCRIPTS->setJavaScriptFile('story_editor', '/javascript/story_editor.js'); if ($_CONF['titletoid']) { $_SCRIPTS->setJavaScriptFile('title_2_id', '/javascript/title_2_id.js'); $story_templates->set_var('titletoid', true); } $_SCRIPTS->setJavaScriptFile('postmode_control', '/javascript/postmode_control.js'); // Loads jQuery UI datepicker and timepicker-addon $_SCRIPTS->setJavaScriptLibrary('jquery.ui.slider'); // $_SCRIPTS->setJavaScriptLibrary('jquery.ui.button'); $_SCRIPTS->setJavaScriptLibrary('jquery.ui.datepicker'); $_SCRIPTS->setJavaScriptLibrary('jquery-ui-i18n'); $_SCRIPTS->setJavaScriptLibrary('jquery-ui-timepicker-addon'); $_SCRIPTS->setJavaScriptLibrary('jquery-ui-timepicker-addon-i18n'); // $_SCRIPTS->setJavaScriptLibrary('jquery-ui-slideraccess'); $_SCRIPTS->setJavaScriptFile('datetimepicker', '/javascript/datetimepicker.js'); $langCode = COM_getLangIso639Code(); $toolTip = $MESSAGE[118]; $imgUrl = $_CONF['site_url'] . '/images/calendar.png'; $_SCRIPTS->setJavaScript("jQuery(function () {" . " geeklog.hour_mode = {$_CONF['hour_mode']};" . " geeklog.datetimepicker.set('publish', '{$langCode}', '{$toolTip}', '{$imgUrl}');" . " geeklog.datetimepicker.set('expire', '{$langCode}', '{$toolTip}', '{$imgUrl}');" . " geeklog.datetimepicker.set('cmt_close', '{$langCode}', '{$toolTip}', '{$imgUrl}');" . "});", TRUE, TRUE); // Setup Advanced Editor COM_setupAdvancedEditor('/javascript/storyeditor_adveditor.js'); $story_templates->set_var('saved_images', $saved_images); $story_templates->set_var('image_form_elements', $fileinputs); $story_templates->set_var('lang_hits', $LANG24[18]); $story_templates->set_var('story_hits', $story->EditElements('hits')); $story_templates->set_var('lang_comments', $LANG24[19]); $story_templates->set_var('story_comments', $story->EditElements('comments')); $story_templates->set_var('lang_trackbacks', $LANG24[29]); $story_templates->set_var('story_trackbacks', $story->EditElements('trackbacks')); $story_templates->set_var('lang_emails', $LANG24[39]); $story_templates->set_var('story_emails', $story->EditElements('numemails')); if ($mode == 'clone') { $story_templates->set_var('story_id', COM_makesid()); } else { $story_templates->set_var('story_id', $story->getSid()); $story_templates->set_var('old_story_id', $story->EditElements('originalSid')); } $story_templates->set_var('lang_sid', $LANG24[12]); $story_templates->set_var('lang_save', $LANG_ADMIN['save']); $story_templates->set_var('lang_preview', $LANG_ADMIN['preview']); $story_templates->set_var('lang_cancel', $LANG_ADMIN['cancel']); $story_templates->set_var('lang_delete', $LANG_ADMIN['delete']); $story_templates->set_var('gltoken_name', CSRF_TOKEN); $token = SEC_createToken(); $story_templates->set_var('gltoken', $token); $story_templates->parse('output', 'editor'); $display .= COM_startBlock($LANG24[5], '', COM_getBlockTemplate('_admin_block', 'header')); $display .= SEC_getTokenExpiryNotice($token, $LANG24[91]); $display .= $story_templates->finish($story_templates->get_var('output')); $display .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')); return $display; }
/** * Shows the story submission form * */ function submitstory() { global $_CONF, $_TABLES, $_USER, $LANG01, $LANG12, $LANG24, $_SCRIPTS; // Add JavaScript $_SCRIPTS->setJavaScriptFile('postmode_control', '/javascript/postmode_control.js'); $retval = ''; $story = new Story(); if (isset($_POST['mode']) && $_POST['mode'] == $LANG12[32]) { // preview $story->loadSubmission(); $retval .= COM_startBlock($LANG12[32]) . STORY_renderArticle($story, 'p') . COM_endBlock(); } else { $story->initSubmission(); } $storyform = COM_newTemplate($_CONF['path_layout'] . 'submit'); if ($_CONF['advanced_editor'] && $_USER['advanced_editor']) { $storyform->set_file('storyform', 'submitstory_advanced.thtml'); $storyform->set_var('change_editormode', 'onchange="change_editmode(this);"'); $storyform->set_var('lang_expandhelp', $LANG24[67]); $storyform->set_var('lang_reducehelp', $LANG24[68]); $link_message = COM_isAnonUser() ? '' : $LANG01[138]; $storyform->set_var('noscript', COM_getNoScript(false, '', $link_message)); // Setup Advanced Editor COM_setupAdvancedEditor('/javascript/submitstory_adveditor.js'); if ($story->EditElements('postmode') === 'html') { $storyform->set_var('show_texteditor', 'none'); $storyform->set_var('show_htmleditor', ''); } else { $storyform->set_var('show_texteditor', ''); $storyform->set_var('show_htmleditor', 'none'); } } else { $storyform->set_file('storyform', 'submitstory.thtml'); if ($story->EditElements('postmode') === 'html') { $storyform->set_var('show_texteditor', 'none'); $storyform->set_var('show_htmleditor', ''); } else { $storyform->set_var('show_texteditor', ''); $storyform->set_var('show_htmleditor', 'none'); } } $storyform->set_var('lang_username', $LANG12[27]); if (!COM_isAnonUser()) { $storyform->set_var('story_username', $_USER['username']); $storyform->set_var('author', COM_getDisplayName()); $storyform->set_var('status_url', $_CONF['site_url'] . '/users.php?mode=logout'); $storyform->set_var('lang_loginout', $LANG12[34]); } else { $storyform->set_var('status_url', $_CONF['site_url'] . '/users.php'); $storyform->set_var('lang_loginout', $LANG12[2]); if (!$_CONF['disable_new_user_registration']) { $storyform->set_var('separator', ' | '); $storyform->set_var('seperator', ' | '); $storyform->set_var('create_account', COM_createLink($LANG12[53], $_CONF['site_url'] . '/users.php?mode=new', array('rel' => 'nofollow'))); } } $storyform->set_var('lang_title', $LANG12[10]); $storyform->set_var('story_title', $story->EditElements('title')); $storyform->set_var('lang_topic', $LANG12[28]); $tlist = TOPIC_getTopicSelectionControl('article', '', false, false, false); $storyform->set_var('topic_selection', $tlist); if (empty($tlist)) { $retval .= COM_showMessage(101); return $retval; } $storyform->set_var('story_topic_options', $tlist); $storyform->set_var('lang_story', $LANG12[29]); $storyform->set_var('lang_introtext', $LANG12[54]); $storyform->set_var('lang_bodytext', $LANG12[55]); $storyform->set_var('story_introtext', $story->EditElements('introtext')); $storyform->set_var('story_bodytext', $story->EditElements('bodytext')); $storyform->set_var('lang_postmode', $LANG12[36]); $postmode = $story->EditElements('postmode'); $storyform->set_var('story_postmode_options', COM_optionList($_TABLES['postmodes'], 'code,name', $postmode)); $allowed_html = ''; foreach (array('plaintext', 'html') as $pm) { $allowed_html .= COM_allowedHTML('story.edit', false, 1, $pm); } $allowed_html .= COM_allowedAutotags(); $storyform->set_var('allowed_html', $allowed_html); $storyform->set_var('story_uid', $story->EditElements('uid')); $storyform->set_var('story_sid', $story->EditElements('sid')); $storyform->set_var('story_date', $story->EditElements('unixdate')); $storyform->set_var('lang_preview', $LANG12[32]); PLG_templateSetVars('story', $storyform); if ($_CONF['skip_preview'] == 1 || isset($_POST['mode']) && $_POST['mode'] == $LANG12[32]) { $storyform->set_var('save_button', '<input name="mode" type="submit" value="' . $LANG12[8] . '"' . XHTML . '>'); } $retval .= COM_startBlock($LANG12[6], 'submitstory.html'); $storyform->parse('theform', 'storyform'); $retval .= $storyform->finish($storyform->get_var('theform')); $retval .= COM_endBlock(); return $retval; }
function openBreadcrumbs() { global $_CONF; $this->_bctemplate = COM_newTemplate($_CONF['path_layout'] . 'navbar'); $this->_bctemplate->set_file(array('breadcrumbs' => 'breadcrumbs.thtml', 'link' => 'breadcrumb_link.thtml')); }
/** * Creates a menu with an optional icon and optional text below * this is used in the admin screens but may be used elsewhere also. * * @param array $menu_arr array of text & URL of the menu entries * @param string $text instructions to be displayed * @param string $icon url of an icon that will be displayed * @return string HTML output of function */ function ADMIN_createMenu($menu_arr, $text, $icon = '') { global $_CONF; $admin_templates = COM_newTemplate($_CONF['path_layout'] . 'admin/lists'); $admin_templates->set_file(array('top_menu' => 'topmenu.thtml')); $menu_fields = ''; $attr = array('class' => 'admin-menu-item'); for ($i = 0; $i < count($menu_arr); $i++) { # iterate through menu $menu_fields .= COM_createLink($menu_arr[$i]['text'], $menu_arr[$i]['url'], $attr); if ($i < count($menu_arr) - 1) { $menu_fields .= ' | '; # add separator } } if (!empty($icon)) { $attr = array('class' => 'admin-menu-icon'); $icon = COM_createImage($icon, '', $attr); $admin_templates->set_var('icon', $icon); } $admin_templates->set_var('menu_fields', $menu_fields); $admin_templates->set_var('lang_instructions', $text); $admin_templates->parse('top_menu', 'top_menu'); $retval = $admin_templates->finish($admin_templates->get_var('top_menu')); return $retval; }
break; case 'addentry': $display .= plugin_submit_calendarjp($mode); $display = COM_createHTMLDocument($display, array('pagetitle' => $pagetitle)); break; case 'savepersonal': if (SEC_checkToken()) { $display = plugin_savesubmission_calendarjp($_POST); } else { $display = COM_refresh($_CONF['site_url'] . '/calendarjp/index.php'); } break; default: // month view // Load templates $cal_templates = COM_newTemplate($_CONF['path'] . 'plugins/calendarjp/templates'); $cal_templates->set_file(array('calendar' => 'calendar' . ($ja ? '_ja' : '') . '.thtml', 'week' => 'calendarweek.thtml', 'day' => 'calendarday.thtml', 'event' => 'calendarevent.thtml', 'mastercal' => 'mastercalendaroption.thtml', 'personalcal' => 'personalcalendaroption.thtml', 'addevent' => 'addeventoption.thtml')); $cal_templates->set_var('mode', $mode); if ($mode == 'personal') { $cal_templates->set_var('start_block', COM_startBlock($LANG_CALJP_2[12])); $cal_templates->set_var('end_block', COM_endBlock()); } else { $cal_templates->set_var('start_block', COM_startBlock($LANG_CALJP_2[11])); $cal_templates->set_var('end_block', COM_endBlock()); } $smallcal_prev = getSmallCalendar($prevmonth, $prevyear, $mode); $cal_templates->set_var('previous_months_calendar', $smallcal_prev); $smallcal_next = getSmallCalendar($nextmonth, $nextyear, $mode); $cal_templates->set_var('next_months_calendar', $smallcal_next); $cal_templates->set_var('cal_prevmo_num', $prevmonth); $cal_templates->set_var('cal_prevyr_num', $prevyear);
/** * Returns an text/image that will display a tooltip * * This tooltip is based on an example from http://downloads.sixrevisions.com/css-tooltips/index.html * * @param string $hoverover Text or image to display for the user to hover their mouse cursor over. * @param string $text Text for the actual tooltip. Can include HTML. * @param string $link Link for the tooltip. If passed, then the hoverover text becomes a link. * @param string $title Text for the tooltip title (if there is one). Can include HTML. * @param string $template Specify a different template to use (classic, critical, help, information, warning). * @param string $class Specify a different tooltip class to use. * @return string HTML tooltip * */ function COM_getTooltip($hoverover = '', $text = '', $link = '', $title = '', $template = 'classic', $class = 'gl-tooltip') { global $_CONF, $_IMAGE_TYPE, $_SCRIPTS; if (!defined('TOOLTIPS_FIXED')) { define('TOOLTIPS_FIXED', true); $_SCRIPTS->setJavaScriptLibrary('jquery'); $_SCRIPTS->setJavaScriptFile('fix_tooltips', '/javascript/fix_tooltips.js'); } if ($hoverover == '') { $hoverover = '<img alt="?" id="gl-tooltip-icon" src="' . $_CONF['layout_url'] . '/tooltips/images/tooltip.' . $_IMAGE_TYPE . '"' . XHTML . '>'; } $tooltip = COM_newTemplate($_CONF['path_layout'] . 'tooltips/'); $tooltip->set_file(array('tooltip' => $template . '.thtml')); $tooltip->set_var('class', $class); $tooltip->set_var('hoverover', $hoverover); $tooltip->set_var('text', $text); $tooltip->set_var('title', $title); if ($link == '') { $link = '#'; $cursor = 'help'; } else { $cursor = 'pointer'; } $tooltip->set_var('link', $link); $tooltip->set_var('cursor', $cursor); $retval = $tooltip->finish($tooltip->parse('output', 'tooltip')); return $retval; }
if ($current_print_page == 0) { $current_print_page = 1; } $total_print_pages = $total_pages; if ($total_print_pages == 0) { $total_print_pages = 1; } $birdseed = MG_getBirdseed(0, 0, 0, $total_print_pages); $ownername = DB_getItem($_TABLES['users'], 'username', "uid=" . intval($root_album->owner_id)); $album_last_update = MG_getUserDateTimeFormat($root_album->last_update); $pagination = COM_printPageNavigation($_MG_CONF['site_url'] . '/index.php', $page + 1, $total_pages); $rsslink = ''; if ($_MG_CONF['rss_full_enabled']) { $rsslink = COM_createLink(COM_createImage(MG_getImageFile('feed.png'), '', array('class' => 'mg_rssimg')), MG_getFeedUrl($_MG_CONF['rss_feed_name'] . '.rss'), array('type' => 'application/rss+xml')); } $T = COM_newTemplate(MG_getTemplatePath_byName($root_album->skin)); $T->set_file('page', 'album_page.thtml'); $T->set_var(array('site_url' => $_MG_CONF['site_url'], 'birdseed' => $birdseed, 'album_title' => PLG_replaceTags($root_album->title), 'table_columns' => $columns_per_page, 'table_column_width' => intval(100 / $columns_per_page) . '%', 'top_pagination' => $pagination, 'bottom_pagination' => $pagination, 'page_number' => sprintf("%s %d %s %d", $LANG_MG03['page'], $current_print_page, $LANG_MG03['of'], $total_print_pages), 'jumpbox' => MG_buildAlbumJumpbox($root_album, $album_id, 1, -1), 'album_id' => $album_id, 'album_description' => $root_album->display_album_desc ? PLG_replaceTags($root_album->description) : '', 'album_id_display' => $root_album->owner_id || $_MG_CONF['enable_media_id'] == 1 ? $LANG_MG03['album_id_display'] . $album_id : '', 'select_adminbox' => COM_isAnonUser() ? '' : MG_buildAdminbox($root_album), 'album_last_update' => $album_last_update[0], 'album_owner' => $ownername, 'media_count' => $root_album->getMediaCount(), 'lang_menulabel' => $LANG_MG03['menulabel'], 'lang_search' => $LANG_MG01['search'], 'rsslink' => $rsslink, 'list_title' => $LANG_MG03['list_title'], 'list_desc' => $LANG_MG03['list_desc'], 'list_size' => $LANG_MG03['list_size'], 'list_user' => $LANG_MG03['list_user'], 'list_updated' => $LANG_MG03['list_updated'])); // completed setting header / footer vars, parse them PLG_templateSetVars('mediagallery', $T); // main processing of the album contents. if ($total_media > 0) { $k = 0; $col = 0; $T->set_block('page', 'ImageColumn', 'IColumn'); $T->set_block('page', 'ImageRow', 'IRow'); for ($i = 0; $i < $media_per_page; $i += $columns_per_page) { $next_columns = $i + $columns_per_page; for ($j = $i; $j < $next_columns; $j++) { if ($j >= $total_media) { $T->parse('IRow', 'ImageRow', true);
/** * Allows user to edit a personal calendar event * * @param array $A Record to display * @return string HTML for event editor * */ function editpersonalevent($A) { global $_CONF, $_CAJP_CONF, $LANG_CALJP_1; $ja = $_CONF['language'] == 'japanese_utf-8'; $cal_templates = COM_newTemplate($_CONF['path'] . 'plugins/calendarjp/templates/'); $cal_templates->set_file('form', 'editpersonalevent' . ($ja ? '_ja' : '') . '.thtml'); $cal_templates->set_var('lang_title', $LANG_CALJP_1[28]); $title = stripslashes($A['title']); $title = str_replace('{', '{', $title); $title = str_replace('}', '}', $title); $title = str_replace('"', '"', $title); $cal_templates->set_var('event_title', $title); $cal_templates->set_var('lang_eventtype', $LANG_CALJP_1[37]); $type_options = CALENDARJP_eventTypeList($A['event_type']); $cal_templates->set_var('type_options', $type_options); // Handle start date/time $cal_templates->set_var('lang_startdate', $LANG_CALJP_1[21]); $cal_templates->set_var('lang_starttime', $LANG_CALJP_1[30]); $A['startdate'] = $A['datestart'] . ' ' . $A['timestart']; $start_month = date('n', strtotime($A['startdate'])); $month_options = CALENDARJP_getMonthFormOptions($start_month); $cal_templates->set_var('startmonth_options', $month_options); $start_day = date('j', strtotime($A['startdate'])); $day_options = COM_getDayFormOptions($start_day); $cal_templates->set_var('startday_options', $day_options); $start_year = date('Y', strtotime($A['startdate'])); $year_options = COM_getYearFormOptions($start_year); $cal_templates->set_var('startyear_options', $year_options); if (isset($_CAJP_CONF['hour_mode']) && $_CAJP_CONF['hour_mode'] == 24) { $start_hour = date('H', strtotime($A['startdate'])); $hour_options = COM_getHourFormOptions($start_hour, 24); $cal_templates->set_var('starthour_options', $hour_options); } else { $start_hour = date('g', strtotime($A['startdate'])); $hour_options = COM_getHourFormOptions($start_hour); $cal_templates->set_var('starthour_options', $hour_options); } $startmin = intval(date('i', strtotime($A['startdate'])) / 15) * 15; $cal_templates->set_var('startminute_options', COM_getMinuteFormOptions($startmin, 15)); $ampm = date('a', strtotime($A['startdate'])); $cal_templates->set_var('startampm_selection', CALENDARJP_getAmPmFormSelection('startampm_selection', $ampm)); // Handle end date/time $cal_templates->set_var('lang_enddate', $LANG_CALJP_1[18]); $cal_templates->set_var('lang_endtime', $LANG_CALJP_1[29]); $A['enddate'] = $A['dateend'] . ' ' . $A['timeend']; $end_month = date('n', strtotime($A['enddate'])); $month_options = CALENDARJP_getMonthFormOptions($end_month); $cal_templates->set_var('endmonth_options', $month_options); $end_day = date('j', strtotime($A['enddate'])); $day_options = COM_getDayFormOptions($end_day); $cal_templates->set_var('endday_options', $day_options); $end_year = date('Y', strtotime($A['enddate'])); $year_options = COM_getYearFormOptions($end_year); $cal_templates->set_var('endyear_options', $year_options); if (isset($_CAJP_CONF['hour_mode']) && $_CAJP_CONF['hour_mode'] == 24) { $end_hour = date('H', strtotime($A['enddate'])); $hour_options = COM_getHourFormOptions($end_hour, 24); $cal_templates->set_var('endhour_options', $hour_options); } else { $end_hour = date('g', strtotime($A['enddate'])); $hour_options = COM_getHourFormOptions($end_hour); $cal_templates->set_var('endhour_options', $hour_options); } $endmin = intval(date('i', strtotime($A['enddate'])) / 15) * 15; $cal_templates->set_var('endminute_options', COM_getMinuteFormOptions($endmin, 15)); $ampm = date('a', strtotime($A['enddate'])); $cal_templates->set_var('endampm_selection', CALENDARJP_getAmPmFormSelection('endampm_selection', $ampm)); $cal_templates->set_var('lang_alldayevent', $LANG_CALJP_1[31]); if ($A['allday'] == 1) { $cal_templates->set_var('allday_checked', 'checked="checked"'); } else { $cal_templates->set_var('allday_checked', ''); } $cal_templates->set_var('lang_tail_year', $LANG_CALJP_1['tail_year']); $cal_templates->set_var('lang_tail_month', $LANG_CALJP_1['tail_month']); $cal_templates->set_var('lang_tail_day', $LANG_CALJP_1['tail_day']); $cal_templates->set_var('lang_location', $LANG_CALJP_1[39]); $cal_templates->set_var('event_location', stripslashes($A['location'])); $cal_templates->set_var('lang_addressline1', $LANG_CALJP_1[32]); $cal_templates->set_var('event_address1', stripslashes($A['address1'])); $cal_templates->set_var('lang_addressline2', $LANG_CALJP_1[33]); $cal_templates->set_var('event_address2', stripslashes($A['address2'])); $cal_templates->set_var('lang_city', $LANG_CALJP_1[34]); $cal_templates->set_var('event_city', stripslashes($A['city'])); $cal_templates->set_var('lang_state', $LANG_CALJP_1[35]); $cal_templates->set_var('state_options', ''); $cal_templates->set_var('event_state', stripslashes($A['state'])); $cal_templates->set_var('lang_zipcode', $LANG_CALJP_1[36]); $cal_templates->set_var('event_zipcode', $A['zipcode']); $cal_templates->set_var('lang_link', $LANG_CALJP_1[43]); $cal_templates->set_var('event_url', $A['url']); $cal_templates->set_var('lang_description', $LANG_CALJP_1[5]); $cal_templates->set_var('event_description', COM_nl2br(stripslashes($A['description']))); $cal_templates->set_var('lang_htmlnotallowed', $LANG_CALJP_1[44]); $cal_templates->set_var('lang_submit', $LANG_CALJP_1[45]); $cal_templates->set_var('lang_delete', $LANG_CALJP_1[51]); $cal_templates->set_var('eid', $A['eid']); $cal_templates->set_var('uid', $A['uid']); if (isset($_CAJP_CONF['hour_mode']) && $_CAJP_CONF['hour_mode'] == 24) { $cal_templates->set_var('hour_mode', 24); } else { $cal_templates->set_var('hour_mode', 12); } $cal_templates->set_var('gltoken_name', CSRF_TOKEN); $cal_templates->set_var('gltoken', SEC_createToken()); return $cal_templates->parse('output', 'form'); }
} $year = COM_applyFilter($year, true); if ($year < 0) { $year = 0; } $month = COM_applyFilter($month, true); if ($month < 1 || $month > 12) { $month = 0; } $dir_topicName = ''; if ($dir_topic !== 'all') { $dir_topicName = DB_getItem($_TABLES['topics'], 'topic', "tid = '" . DB_escapeString($dir_topic) . "'"); } $template = null; if (TEMPLATE_EXISTS) { $template = COM_newTemplate($_CONF['path_layout']); $template->set_file('t_directory', 'directory.thtml'); $template->set_block('t_directory', 'section-title'); $template->set_block('t_directory', 'no-articles'); $template->set_var('lang_no_articles', $LANG_DIR['no_articles']); } if ($year != 0 && $month != 0) { $title = sprintf($LANG_DIR['title_month_year'], $LANG_MONTH[$month], $year); if ($dir_topic !== 'all') { $title .= ': ' . $dir_topicName; } $headerCode = DIR_canonicalLink($dir_topic, $year, $month); $directory = DIR_displayMonth($template, $dir_topic, $year, $month); $page_navigation = DIR_navBar($dir_topic, $year, $month); $block_title = $LANG_MONTH[$month] . ' ' . $year; $val_year = $year;
$addmod->set_var('LANG_DELETE', $LANG_GF01['DELETE']); $addmod->set_var('gltoken_name', CSRF_TOKEN); $addmod->set_var('gltoken', SEC_createToken()); $addmod->parse('output', 'moderator'); $display .= $addmod->finish($addmod->get_var('output')); } else { $showforumssql = DB_query("SELECT forum_name,forum_id FROM {$_TABLES['forum_forums']}"); $sel_forums = '<option value="0">' . $LANG_GF93['allforums'] . '</option>'; while ($showforum = DB_fetchArray($showforumssql)) { if ($selected_forum == $showforum['forum_id']) { $sel_forums .= '<option value="' . $showforum['forum_id'] . '" selected="selected">' . $showforum['forum_name'] . '</option>'; } else { $sel_forums .= '<option value="' . $showforum['forum_id'] . '">' . $showforum['forum_name'] . '</option>'; } } $moderators = COM_newTemplate($CONF_FORUM['path_layout'] . 'forum/layout/admin'); $moderators->set_file(array('moderators' => 'moderators.thtml', 'mod_record' => 'mod_record.thtml')); $moderators->set_var('action_url', $_CONF['site_admin_url'] . '/plugins/forum/mods.php'); $moderators->set_var('imgset', $CONF_FORUM['imgset']); $moderators->set_var('userfilter', ''); if ($filtermode == 'group') { $moderators->set_var('groupfilter', 'checked="checked"'); $moderators->set_var('LANG_HEADING2', $LANG_GF01['GROUP']); } else { $moderators->set_var('userfilter', 'checked="checked"'); $moderators->set_var('LANG_HEADING2', $LANG_GF01['USER']); } $moderators->set_var('LANG_filtertitle', $LANG_GF93['filtertitle']); $moderators->set_var('LANG_username', $LANG_GF01['USER']); $moderators->set_var('LANG_FORUM', $LANG_GF01['FORUM']); $moderators->set_var('LANG_BAN', $LANG_GF93['ModBan']);
/** * Continues a session - handles timeout, looping, etc. * * @parm char session id to continue * @parm int number of items to process per run * 0 indicates initial run * @return char HTML of status screen */ function MG_continueSession($session_id, $item_limit, $refresh_rate) { global $_CONF, $_MG_CONF, $_TABLES, $_USER, $LANG_MG00, $LANG_MG01, $LANG_MG02; $retval = ''; $cycle_start_time = time(); $temp_time = array(); $timer_expired = false; $num_rows = 0; $session_id = COM_applyFilter($session_id); // Pull the session status info $sql = "SELECT * FROM {$_TABLES['mg_sessions']} " . "WHERE session_id='" . addslashes($session_id) . "'"; $result = DB_query($sql, 1); if (DB_error()) { COM_errorLog("MediaGallery: Error - Unable to retrieve batch session data"); return ''; } $nRows = DB_numRows($result); if ($nRows > 0) { $session = DB_fetchArray($result); } else { COM_errorLog("MediaGallery: Error - Unable to find batch session id"); return ''; // no session found } // security check - make sure we are continuing a session that we own... if ($session['session_uid'] != $_USER['uid'] && !SEC_hasRights('mediagallery.admin')) { return COM_showMessageText($LANG_MG00['access_denied_msg']); } // Setup timer information $time_limit = $_MG_CONF['def_time_limit']; @set_time_limit($time_limit + 20); // get execution time $max_execution_time = ini_get('max_execution_time'); if ($time_limit > $max_execution_time) { $time_limit = $max_execution_time; } $label = COM_stripslashes($session['session_description']); // Pull the detail data from the sessions_items table... $sql = "SELECT * FROM {$_TABLES['mg_session_items']} " . "WHERE session_id='" . addslashes($session_id) . "' " . "AND status=0 LIMIT " . $item_limit; $result = DB_query($sql); while (($row = DB_fetchArray($result)) && $timer_expired == false) { // used for calculating loop duration and changing the timer condition $start_temp_time = time(); $function = 'mg_batch_session_' . $session['session_action']; if (function_exists($function)) { $function($row); DB_change($_TABLES['mg_session_items'], 'status', 1, 'id', $row['id']); } // calculate time for each loop iteration $temp_time[$num_rows] = time() - $start_temp_time; // get the max $timer_time = max($temp_time); $num_rows++; // check if timer is about to expire if (time() - $cycle_start_time >= $time_limit - $timer_time) { $timer_expired_secs = time() - $cycle_start_time; $timer_expired = true; } } // end the timer $cycle_end_time = time(); // find how much time the last cycle took $last_cycle_time = $cycle_end_time - $cycle_start_time; $T = COM_newTemplate(MG_getTemplatePath(0)); $T->set_file('batch', 'batch_progress.thtml'); $processing_messages = ''; if ($timer_expired) { $processing_messages = '<p>' . sprintf($LANG_MG01['timer_expired'], $timer_expired_secs) . '</p>'; } $sql = "SELECT COUNT(*) AS processed " . "FROM {$_TABLES['mg_session_items']} " . "WHERE session_id='" . addslashes($session_id) . "' AND status=1"; $result = DB_query($sql); $row = DB_fetchArray($result); $session_items_processed = $row['processed']; $sql = "SELECT COUNT(*) AS processing " . "FROM {$_TABLES['mg_session_items']} " . "WHERE session_id='" . addslashes($session_id) . "'"; $result = DB_query($sql); $row = DB_fetchArray($result); $session_items_processing = $row['processing']; $items_remaining = $session_items_processing - $session_items_processed; if ($items_remaining > 0) { if ($item_limit == 0) { $processing_messages .= '<p>' . $LANG_MG01['begin_processing'] . '</p>'; $item_limit = $_MG_CONF['def_item_limit']; } else { $processing_messages .= '<p>' . sprintf($LANG_MG01['processing_next_items'], $item_limit) . '</p>'; } $form_action = $_MG_CONF['site_url'] . '/batch.php?mode=continue&sid=' . $session_id . '&refresh=' . $refresh_rate . '&limit=' . $item_limit; $next_button = $LANG_MG01['next']; // create the meta tag for refresh $T->set_var("META", '<meta http-equiv="refresh" content="' . $refresh_rate . ';url=' . $form_action . '"' . XHTML . '>'); } else { if ($item_limit == 0) { echo COM_refresh($session['session_origin']); exit; } $next_button = $LANG_MG01['finished']; $processing_messages .= '<p>' . $LANG_MG01['all_done'] . '</p>'; $T->set_var("META", ''); $refresh_rate = -1; $form_action = $session['session_origin']; $result = DB_query("SELECT * FROM {$_TABLES['mg_session_log']} " . "WHERE session_id='" . addslashes($session_id) . "'"); while ($row = DB_fetchArray($result)) { $processing_messages .= '<p>' . $row['session_log'] . '</p>'; } MG_endSession($session_id); } $session_percent = $session_items_processed / $session_items_processing * 100; $session_time = $cycle_end_time - $session['session_start_time']; $T->set_var(array('L_BATCH_PROCESS' => $label, 'L_BATCH' => $LANG_MG01['batch_sessions'], 'L_NEXT' => $next_button, 'L_PROCESSING' => $LANG_MG01['processing'], 'L_CANCEL' => $LANG_MG01['cancel'], 'L_PROCESSING_DETAILS' => $LANG_MG01['processing_details'], 'L_STATUS' => $LANG_MG01['status'], 'L_TOTAL_ITEMS' => $LANG_MG01['total_items'], 'L_ITEMS_PROCESSED' => $LANG_MG01['processed_items'], 'L_ITEMS_REMAINING' => $LANG_MG01['items_remaining'], 'L_POSTS_LAST_CYCLE' => $LANG_MG01['items_last_cycle'], 'L_TIME_LIMIT' => $LANG_MG01['time_limit'], 'L_REFRESH_RATE' => $LANG_MG01['refresh_rate'], 'L_ITEM_RATE' => $LANG_MG01['item_rate'], 'L_ACTIVE_PARAMETERS' => $LANG_MG01['batch_parameters'], 'L_ITEMS_PER_CYCLE' => $LANG_MG01['items_per_cycle'], 'TOTAL_ITEMS' => $session_items_processing, 'ITEMS_PROCESSED' => $session_items_processed, 'ITEMS_REMAINING' => $session_items_processing - $session_items_processed, 'ITEM_RATE' => sprintf($LANG_MG01['seconds_per_item'], round(@($last_cycle_time / $num_rows))), 'PROCESSING_MESSAGES' => $processing_messages, 'SESSION_PERCENT' => round($session_percent, 2) . ' %', 'POST_LIMIT' => $num_rows, 'ITEM_LIMIT' => $item_limit, 'TIME_LIMIT' => $time_limit, 'REFRESH_RATE' => $refresh_rate, 'S_BATCH_ACTION' => $form_action)); $retval .= $T->finish($T->parse('output', 'batch')); return $retval; }
$report->set_var('post_replies', $P['replies']); $report->set_var('post_views', $P['views']); $report->set_var('csscode', $i % 2 + 1); $report->parse('report_records', 'records', true); } } $link = "<p><a href=\"{$_CONF['site_url']}/forum/memberlist.php?order={$order}&prevorder={$prevorder}"; $link .= "&direction={$direction}&page={$page}\">{$LANG_GF02['msg169']}</a></p>"; $report->set_var('bottomlink', $link); $report->parse('output', 'report'); $display .= $report->finish($report->get_var('output')); $display = gf_createHTMLDocument($display); COM_output($display); exit; } else { $report = COM_newTemplate($CONF_FORUM['path_layout'] . 'forum/layout'); $report->set_file(array('report' => 'reports/memberlist.thtml', 'records' => 'reports/memberlist_line.thtml', 'link' => 'reports/memberlist_link.thtml', 'outline_header' => 'forum_outline_header.thtml', 'outline_footer' => 'forum_outline_footer.thtml')); // Check if the number of records was specified to show if (empty($show) and $CONF_FORUM['show_members_perpage'] > 0) { $show = $CONF_FORUM['show_members_perpage']; } elseif (empty($show)) { $show = 20; } // Check if this is the first page. if ($page == 0) { $page = 1; } if ($prevorder != $order) { $direction = 'desc'; } switch ($order) {
function links_edit_category($cid, $pid) { global $_CONF, $_TABLES, $_USER, $MESSAGE, $LANG_LINKS_ADMIN, $LANG_ADMIN, $LANG_ACCESS, $_LI_CONF; $retval = ''; $cid = DB_escapeString($cid); if (!empty($pid)) { // have parent id, so making a new subcategory // get parent access rights $result = DB_query("SELECT group_id,perm_owner,perm_group,perm_members,perm_anon FROM {$_TABLES['linkcategories']} WHERE cid='" . DB_escapeString($pid) . "'"); $A = DB_fetchArray($result); $A['owner_id'] = $_USER['uid']; $A['pid'] = $pid; } elseif (!empty($cid)) { // have category id, so editing a category $sql = "SELECT * FROM {$_TABLES['linkcategories']} WHERE cid='{$cid}'" . COM_getPermSQL('AND'); $result = DB_query($sql); $A = DB_fetchArray($result); } else { // nothing, so making a new top-level category // get default access rights $A['group_id'] = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name='Links Admin'"); SEC_setDefaultPermissions($A, $_LI_CONF['category_permissions']); $A['owner_id'] = $_USER['uid']; $A['pid'] = $_LI_CONF['root']; } $access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']); if ($access < 3) { return COM_showMessage(6, 'links'); } $token = SEC_createToken(); $retval .= COM_startBlock($LANG_LINKS_ADMIN[56], '', COM_getBlockTemplate('_admin_block', 'header')); $retval .= SEC_getTokenExpiryNotice($token); $T = COM_newTemplate(CTL_plugin_templatePath('links', 'admin')); $T->set_file(array('page' => 'categoryeditor.thtml')); $T->set_var('lang_pagetitle', $LANG_LINKS_ADMIN[28]); $T->set_var('lang_link_list', $LANG_LINKS_ADMIN[53]); $T->set_var('lang_new_link', $LANG_LINKS_ADMIN[51]); $T->set_var('lang_validate_links', $LANG_LINKS_ADMIN[26]); $T->set_var('lang_list_categories', $LANG_LINKS_ADMIN[50]); $T->set_var('lang_new_category', $LANG_LINKS_ADMIN[52]); $T->set_var('lang_admin_home', $LANG_ADMIN['admin_home']); $T->set_var('instructions', $LANG_LINKS_ADMIN[29]); $T->set_var('lang_category', $LANG_LINKS_ADMIN[30]); $T->set_var('lang_cid', $LANG_LINKS_ADMIN[32]); $T->set_var('lang_description', $LANG_LINKS_ADMIN[31]); $T->set_var('lang_topic', $LANG_LINKS_ADMIN[33]); $T->set_var('lang_parent', $LANG_LINKS_ADMIN[34]); $T->set_var('lang_save', $LANG_ADMIN['save']); if (!empty($cid)) { $delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="mode"%s' . XHTML . '>'; $jsconfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"'; $T->set_var('delete_option', sprintf($delbutton, $jsconfirm)); $T->set_var('delete_option_no_confirmation', sprintf($delbutton, '')); $T->set_var('allow_delete', true); $T->set_var('lang_delete', $LANG_ADMIN['delete']); $T->set_var('confirm_message', $MESSAGE[76]); } else { $T->set_var('delete_option', ''); } $T->set_var('lang_cancel', $LANG_ADMIN['cancel']); if (!empty($cid)) { $T->set_var('cid_value', $A['cid']); $T->set_var('old_cid_value', $A['cid']); $T->set_var('category_options', links_select_box(3, $A['pid'])); $T->set_var('category_value', $A['category']); $T->set_var('description_value', $A['description']); } else { $A['cid'] = COM_makeSid(); $T->set_var('cid_value', $A['cid']); $T->set_var('old_cid_value', ''); $T->set_var('category_options', links_select_box(3, $A['pid'])); $T->set_var('category_value', ''); $T->set_var('description_value', ''); } if (!isset($A['tid'])) { $A['tid'] = TOPIC_ALL_OPTION; } /* $topics = COM_topicList('tid,topic', $A['tid'], 1, true); $T->set_var('topic_list', $topics); $alltopics = '<option value="all"'; if ($A['tid'] == 'all') { $alltopics .= ' selected="selected"'; } $alltopics .= '>' . $LANG_LINKS_ADMIN[35] . '</option>' . LB; $T->set_var('topic_selection', '<select name="tid">' . $alltopics . $topics . '</select>'); */ $T->set_var('topic_selection', '<select name="tid" id="tid">' . TOPIC_getTopicListSelect($A['tid'], 2, true) . '</select>'); if (empty($cid)) { $num_links = $LANG_ADMIN['na']; } else { $nresult = DB_query("SELECT COUNT(*) AS count FROM {$_TABLES['links']} WHERE cid='{$cid}'" . COM_getPermSQL('AND')); $N = DB_fetchArray($nresult); $num_links = COM_numberFormat($N['count']); } $T->set_var('lang_num_links', $LANG_LINKS_ADMIN[61]); $T->set_var('num_links', $num_links); // user access info $T->set_var('lang_accessrights', $LANG_ACCESS['accessrights']); $T->set_var('lang_owner', $LANG_ACCESS['owner']); $T->set_var('owner_name', COM_getDisplayName($A['owner_id'])); $T->set_var('cat_ownerid', $A['owner_id']); $T->set_var('lang_group', $LANG_ACCESS['group']); $T->set_var('group_dropdown', SEC_getGroupDropdown($A['group_id'], $access)); $T->set_var('lang_permissions', $LANG_ACCESS['permissions']); $T->set_var('lang_permissionskey', $LANG_ACCESS['permissionskey']); $T->set_var('lang_perm_key', $LANG_ACCESS['permissionskey']); $T->set_var('permissions_editor', SEC_getPermissionsHTML($A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon'])); $T->set_var('lang_permissions_msg', $LANG_ACCESS['permmsg']); $T->set_var('lang_lockmsg', $LANG_ACCESS['permmsg']); $T->set_var('gltoken_name', CSRF_TOKEN); $T->set_var('gltoken', $token); $T->parse('output', 'page'); $retval .= $T->finish($T->get_var('output')); $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')); return $retval; }
/** * Displays a login form * This is the version of the login form displayed in the content area of the * page (not the side bar). It will present all options (remote authentication * - including OpenID, new registration link, etc.) according to the current * configuration settings. * * @param array $use_config options to override some of the defaults * @return string HTML of the login form */ function SEC_loginForm($use_config = array()) { global $_CONF, $LANG01, $LANG04, $_SCRIPTS; $retval = ''; $have_remote_login = false; $default_config = array('hide_forgotpw_link' => false, 'hidden_fields' => '', 'no_oauth_login' => false, 'no_3rdparty_login' => false, 'no_openid_login' => false, 'no_newreg_link' => false, 'no_plugin_vars' => false, 'title' => $LANG04[65], 'message' => $LANG04[66], 'button_text' => $LANG04[80]); $config = array_merge($default_config, $use_config); $loginform = COM_newTemplate($_CONF['path_layout'] . 'users'); $loginform->set_file('login', 'loginform.thtml'); $loginform->set_var('start_block_loginagain', COM_startBlock($config['title'])); $loginform->set_var('lang_message', $config['message']); if ($config['no_newreg_link'] || $_CONF['disable_new_user_registration']) { $loginform->set_var('lang_newreglink', ''); } else { $loginform->set_var('lang_newreglink', $LANG04[123]); } $loginform->set_var('lang_username', $LANG04[2]); $loginform->set_var('lang_password', $LANG01[57]); if ($config['hide_forgotpw_link']) { $loginform->set_var('lang_forgetpassword', ''); $loginform->set_var('forgetpassword_link', ''); } else { $loginform->set_var('lang_forgetpassword', $LANG04[25]); $forget = COM_createLink($LANG04[25], $_CONF['site_url'] . '/users.php?mode=getpassword', array('rel' => 'nofollow')); $loginform->set_var('forgetpassword_link', $forget); } $loginform->set_var('lang_login', $config['button_text']); $loginform->set_var('lang_remote_login', $LANG04[167]); $loginform->set_var('lang_remote_login_desc', $LANG04[168]); $loginform->set_var('end_block', COM_endBlock()); // 3rd party remote authentification. $services = ''; if (!$config['no_3rdparty_login'] && $_CONF['user_login_method']['3rdparty'] && $_CONF['usersubmission'] == 0) { $modules = SEC_collectRemoteAuthenticationModules(); if (count($modules) > 0) { if (!$_CONF['user_login_method']['standard'] && count($modules) == 1) { $select = '<input type="hidden" name="service" value="' . $modules[0] . '"' . XHTML . '>' . $modules[0]; } else { // Build select $select = '<select name="service">'; if ($_CONF['user_login_method']['standard']) { $select .= '<option value="">' . $_CONF['site_name'] . '</option>'; } foreach ($modules as $service) { $select .= '<option value="' . $service . '">' . $service . '</option>'; } $select .= '</select>'; } $loginform->set_file('services', 'services.thtml'); $loginform->set_var('lang_service', $LANG04[121]); $loginform->set_var('select_service', $select); $loginform->parse('output', 'services'); $services .= $loginform->finish($loginform->get_var('output')); } } if (!empty($config['hidden_fields'])) { // allow caller to (ab)use {services} for hidden fields $services .= $config['hidden_fields']; } $loginform->set_var('services', $services); // OpenID remote authentification. if (!$config['no_openid_login'] && $_CONF['user_login_method']['openid'] && $_CONF['usersubmission'] == 0 && !$_CONF['disable_new_user_registration']) { $have_remote_login = true; $_SCRIPTS->setJavascriptFile('login', '/javascript/login.js'); $loginform->set_file('openid_login', '../loginform_openid.thtml'); $loginform->set_var('lang_openid_login', $LANG01[128]); $loginform->set_var('input_field_size', 40); // for backward compatibility - not used any more $app_url = isset($_SERVER['SCRIPT_URI']) ? $_SERVER['SCRIPT_URI'] : 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; $loginform->set_var('app_url', $app_url); $loginform->parse('output', 'openid_login'); $loginform->set_var('openid_login', $loginform->finish($loginform->get_var('output'))); } else { $loginform->set_var('openid_login', ''); } // OAuth remote authentification. if (!$config['no_oauth_login'] && $_CONF['user_login_method']['oauth'] && $_CONF['usersubmission'] == 0 && !$_CONF['disable_new_user_registration']) { $have_remote_login = true; $_SCRIPTS->setJavascriptFile('login', '/javascript/login.js'); $modules = SEC_collectRemoteOAuthModules(); if (count($modules) == 0) { $loginform->set_var('oauth_login', ''); } else { $html_oauth = ''; // Grab oauth icons from theme if ($_CONF['theme_oauth_icons']) { $icon_path = $_CONF['layout_url'] . '/images/'; } else { $icon_path = $_CONF['site_url'] . '/images/'; } foreach ($modules as $service) { $loginform->set_file('oauth_login', '../loginform_oauth.thtml'); $loginform->set_var('oauth_service', $service); $loginform->set_var('lang_oauth_service', $LANG01[$service]); // for sign in image $loginform->set_var('oauth_sign_in_image', $icon_path . $service . '-login-icon.png'); $loginform->parse('output', 'oauth_login'); $html_oauth .= $loginform->finish($loginform->get_var('output')); } $loginform->set_var('oauth_login', $html_oauth); } } else { $loginform->set_var('oauth_login', ''); } if ($have_remote_login) { $loginform->set_var('remote_login_class', 'remote-login-enabled'); } if (!$config['no_plugin_vars']) { PLG_templateSetVars('loginform', $loginform); } $loginform->parse('output', 'login'); $retval .= $loginform->finish($loginform->get_var('output')); return $retval; }
/** * Render all the trackback comments for a specific entry * * @param string $sid entry id * @param string $type type of entry ('article' = story, etc.) * @param string $title the entry's title * @param string $permalink link to the entry * @param string trackback_url trackback URL for this entry * @return string HTML (formatted list of trackback comments) * */ function TRB_renderTrackbackComments($sid, $type, $title, $permalink, $trackback_url = '') { global $_CONF, $_TABLES, $LANG_TRB; $link_and_title = COM_createLink($title, $permalink); if (empty($trackback_url)) { $trackback_url = TRB_makeTrackbackUrl($sid, $type); } $template = COM_newTemplate($_CONF['path_layout'] . 'trackback'); $template->set_file(array('trackback' => 'trackback.thtml', 'comment' => 'trackbackcomment.thtml')); $template->set_var('lang_trackback', $LANG_TRB['trackback']); $template->set_var('lang_trackback_url', $LANG_TRB['this_trackback_url']); $template->set_var('permalink', $permalink); $template->set_var('permalink_and_title', $link_and_title); $template->set_var('trackback_url', $trackback_url); $result = DB_query("SELECT cid,url,title,blog,excerpt,ipaddress,UNIX_TIMESTAMP(date) AS day " . "FROM {$_TABLES['trackback']} WHERE sid = '{$sid}' AND type = '{$type}' ORDER BY date"); $numrows = DB_numRows($result); $template->set_var('trackback_comment_count', $numrows); $num_comments = sprintf($LANG_TRB['num_comments'], $numrows); $template->set_var('trackback_comment_text', $num_comments); if ($numrows == 0) { $template->set_var('lang_trackback_comments', $LANG_TRB['no_comments']); $template->set_var('lang_trackback_comments_no_link', $LANG_TRB['no_comments']); } else { $template->set_var('lang_trackback_comments', sprintf($LANG_TRB['intro_text'], $link_and_title)); $template->set_var('lang_trackback_comments_no_link', sprintf($LANG_TRB['intro_text'], $title)); } $delete_option = TRB_allowDelete($sid, $type); $token = ''; if ($delete_option && $numrows > 0) { $token = SEC_createToken(); } for ($i = 0; $i < $numrows; $i++) { $A = DB_fetchArray($result); $comment = TRB_formatComment($A['url'], $A['title'], $A['blog'], $A['excerpt'], $A['day'], $delete_option, $A['cid'], $A['ipaddress'], $token); $template->set_var('formatted_comment', $comment); $template->parse('trackback_comments', 'comment', true); } $template->parse('output', 'trackback'); return $template->finish($template->get_var('output')); }
/** * This function used to send out reminders to users to access the site or account may be deleted * * @return string HTML with success or error message * */ function batchreminders() { global $_CONF, $_TABLES, $LANG04, $LANG28; $msg = ''; $user_list = array(); if (isset($_POST['delitem'])) { $user_list = $_POST['delitem']; } if (count($user_list) == 0) { $msg = $LANG28[79] . '<br' . XHTML . '>'; } $c = 0; if (isset($_POST['delitem']) and is_array($_POST['delitem'])) { foreach ($_POST['delitem'] as $delitem) { $userid = COM_applyFilter($delitem); $useremail = DB_getItem($_TABLES['users'], 'email', "uid = '{$userid}'"); $username = DB_getItem($_TABLES['users'], 'username', "uid = '{$userid}'"); $lastlogin = DB_getItem($_TABLES['userinfo'], 'lastlogin', "uid = '{$userid}'"); $lasttime = COM_getUserDateTimeFormat($lastlogin); if (file_exists($_CONF['path_data'] . 'reminder_email.txt')) { $template = COM_newTemplate($_CONF['path_data']); $template->set_file(array('mail' => 'reminder_email.txt')); $template->set_var('site_name', $_CONF['site_name']); $template->set_var('site_slogan', $_CONF['site_slogan']); $template->set_var('lang_username', $LANG04[2]); $template->set_var('username', $username); $template->set_var('name', COM_getDisplayName($uid)); $template->set_var('lastlogin', $lasttime[0]); $template->parse('output', 'mail'); $mailtext = $template->finish($template->get_var('output')); } else { if ($lastlogin == 0) { $mailtext = $LANG28[83] . "\n\n"; } else { $mailtext = sprintf($LANG28[82], $lasttime[0]) . "\n\n"; } $mailtext .= sprintf($LANG28[84], $username) . "\n"; $mailtext .= sprintf($LANG28[85], $_CONF['site_url'] . '/users.php?mode=getpassword') . "\n\n"; } $subject = sprintf($LANG28[81], $_CONF['site_name']); if ($_CONF['site_mail'] !== $_CONF['noreply_mail']) { $mailfrom = $_CONF['noreply_mail']; $mailtext .= LB . LB . $LANG04[159]; } else { $mailfrom = $_CONF['site_mail']; } if (COM_mail($useremail, $subject, $mailtext, $mailfrom)) { DB_query("UPDATE {$_TABLES['users']} SET num_reminders=num_reminders+1 WHERE uid={$userid}"); $c++; } else { COM_errorLog("Error attempting to send account reminder to use:{$username} ({$userid})"); } } } // Since this function is used for deletion only, its necessary to say that // zero where deleted instead of just leaving this message away. COM_numberFormat($c); // just in case we have more than 999).. $msg .= "{$LANG28[80]}: {$c}<br" . XHTML . ">\n"; return $msg; }
/** * Takes an article class and renders HTML in the specified template and style. * Formats the given article into HTML. Called by index.php, article.php, * submit.php and admin/story.php (Preview mode for the last two). * * @param Story $story The story to display, an instance of the Story class. * @param string $index n = Full display of article. p = 'Preview' mode. Else introtext only. * @param string $storyTpl The template to use to render the story. * @param string $query A search query, if one was specified. * @return string Article as formatted HTML. * Note: Formerly named COM_Article, and re-written totally since then. */ function STORY_renderArticle($story, $index = '', $storyTpl = 'storytext.thtml', $query = '') { global $_CONF, $_TABLES, $_USER, $LANG01, $LANG05, $LANG11, $LANG_TRB, $_IMAGE_TYPE, $mode; static $storyCounter = 0; if ($story->DisplayElements('featured') == 1) { $article_filevar = 'featuredarticle'; } elseif ($story->DisplayElements('statuscode') == STORY_ARCHIVE_ON_EXPIRE && $story->DisplayElements('expire') <= time()) { $article_filevar = 'archivearticle'; } else { $article_filevar = 'article'; } if (empty($storyTpl)) { $storyTpl = 'storytext.thtml'; } // Change article template file with the topic (feature request #275) $templateDir = $_CONF['path_layout']; $topicDir = $templateDir . 'topics/' . $story->DisplayElements('tid') . '/'; if (is_dir($topicDir) && file_exists($topicDir . $storyTpl)) { $templateDir = $topicDir; } $article = COM_newTemplate($templateDir); $article->set_file(array('article' => $storyTpl, 'bodytext' => 'storybodytext.thtml', 'featuredarticle' => 'featuredstorytext.thtml', 'featuredbodytext' => 'featuredstorybodytext.thtml', 'archivearticle' => 'archivestorytext.thtml', 'archivebodytext' => 'archivestorybodytext.thtml')); // begin instance caching... $cache_time = $story->DisplayElements('cache_time'); $current_article_tid = $story->DisplayElements('tid'); $retval = false; // If stays false will rebuild article and not used cache (checks done below) if ($cache_time > 0 || $cache_time == -1) { $hash = CACHE_security_hash(); $cacheInstance = 'article__' . $story->getSid() . '_' . $index . $mode . '_' . $article_filevar . '_' . $current_article_tid . '_' . $hash . '_' . $_USER['theme']; if ($_CONF['cache_templates']) { $retval = $article->check_instance($cacheInstance, $article_filevar); } else { $retval = CACHE_check_instance($cacheInstance); } if ($retval && $cache_time == -1) { // Cache file found so use it since no time limit set to recreate } elseif ($retval && $cache_time > 0) { $lu = CACHE_get_instance_update($cacheInstance); $now = time(); if ($now - $lu < $cache_time) { // Cache file found so use it since under time limit set to recreate } else { // generate article and create cache file // Cache time is not built into template caching so need to delete it manually and reset $retval if ($_CONF['cache_templates']) { // Need to close and recreate template class since issues arise when theme templates are cached unset($article); // Close template class CACHE_remove_instance($cacheInstance); $article = COM_newTemplate($_CONF['path_layout']); $article->set_file(array('article' => $storyTpl, 'bodytext' => 'storybodytext.thtml', 'featuredarticle' => 'featuredstorytext.thtml', 'featuredbodytext' => 'featuredstorybodytext.thtml', 'archivearticle' => 'archivestorytext.thtml', 'archivebodytext' => 'archivestorybodytext.thtml')); } else { // theme templates are not cache so can go ahead and delete story cache CACHE_remove_instance($cacheInstance); } $retval = false; } } else { // Need to reset especially if caching is disabled for a certain story but template caching has been enabled for the theme $retval = false; } } $articleUrl = COM_buildURL($_CONF['site_url'] . '/article.php?story=' . $story->getSid()); $article->set_var('article_url', $articleUrl); $article->set_var('story_title', $story->DisplayElements('title')); // Date formatting set by user therefore cannot be cached $article->set_var('story_date', $story->DisplayElements('date'), false, true); $article->set_var('story_datetime', $story->DisplayElements('datetime'), false, true); // Story views increase with every visit so cannot be cached if ($_CONF['hideviewscount'] != 1) { $article->set_var('lang_views', $LANG01[106], false, true); $article->set_var('story_hits', $story->DisplayElements('hits'), false, true); } // Topic Icon is user configurable so do not cache $topicname = $story->DisplayElements('topic'); $topicurl = COM_buildURL($_CONF['site_url'] . '/index.php?topic=' . $story->DisplayElements('tid')); if ((!isset($_USER['noicons']) || $_USER['noicons'] != 1) && $story->DisplayElements('show_topic_icon') == 1) { $imageurl = $story->DisplayElements('imageurl'); if (!empty($imageurl)) { $imageurl = COM_getTopicImageUrl($imageurl); $article->set_var('story_topic_image_url', $imageurl, false, true); $topicimage = '<img src="' . $imageurl . '" class="float' . $_CONF['article_image_align'] . '" alt="' . $topicname . '" title="' . $topicname . '"' . XHTML . '>'; $article->set_var('story_anchortag_and_image', COM_createLink($topicimage, $topicurl, array()), false, true); $article->set_var('story_topic_image', $topicimage, false, true); $topicimage_noalign = '<img src="' . $imageurl . '" alt="' . $topicname . '" title="' . $topicname . '"' . XHTML . '>'; $article->set_var('story_anchortag_and_image_no_align', COM_createLink($topicimage_noalign, $topicurl, array()), false, true); $article->set_var('story_topic_image_no_align', $topicimage_noalign, false, true); } } // Main article content if ($index == 'p') { $introtext = $story->getPreviewText('introtext'); $bodytext = $story->getPreviewText('bodytext'); } else { $introtext = $story->displayElements('introtext'); $bodytext = $story->displayElements('bodytext'); } $readmore = empty($bodytext) ? 0 : 1; $numwords = COM_numberFormat(count(explode(' ', COM_getTextContent($bodytext)))); if (COM_onFrontpage()) { $bodytext = ''; } if (!empty($query)) { $introtext = COM_highlightQuery($introtext, $query); $bodytext = COM_highlightQuery($bodytext, $query); } // Create article only if preview, or query not empty, or if no cache version or cache version is not required if ($index == 'p' || !empty($query) || !$retval) { $article->set_var('article_filevar', ''); $article->set_var('site_name', $_CONF['site_name']); //$article->set_var( 'story_date', $story->DisplayElements('date') ); $article->set_var('story_date_short', $story->DisplayElements('shortdate')); $article->set_var('story_date_only', $story->DisplayElements('dateonly')); $article->set_var('story_id', $story->getSid()); if ($_CONF['contributedbyline'] == 1) { $article->set_var('lang_contributed_by', $LANG01[1]); $article->set_var('contributedby_uid', $story->DisplayElements('uid')); $fullname = $story->DisplayElements('fullname'); $username = $story->DisplayElements('username'); $article->set_var('contributedby_user', $username); if (empty($fullname)) { $article->set_var('contributedby_fullname', $username); } else { $article->set_var('contributedby_fullname', $fullname); } $authorname = COM_getDisplayName($story->DisplayElements('uid'), $username, $fullname); $article->set_var('contributedby_author', $authorname); $article->set_var('author', $authorname); $profileUrl = ''; if ($story->DisplayElements('uid') > 1) { $profileUrl = $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $story->DisplayElements('uid'); $article->set_var('start_contributedby_anchortag', '<a class="storybyline" href="' . $profileUrl . '" rel="author">'); $article->set_var('end_contributedby_anchortag', '</a>'); $article->set_var('contributedby_url', $profileUrl); } $photo = ''; if ($_CONF['allow_user_photo'] == 1) { $authphoto = $story->DisplayElements('photo'); if (empty($authphoto)) { $authphoto = '(none)'; // user does not have a photo } $photo = USER_getPhoto($story->DisplayElements('uid'), $authphoto, $story->DisplayElements('email')); } if (!empty($photo)) { $article->set_var('contributedby_photo', $photo); $article->set_var('author_photo', $photo); $camera_icon = '<img src="' . $_CONF['layout_url'] . '/images/smallcamera.' . $_IMAGE_TYPE . '" alt=""' . XHTML . '>'; $article->set_var('camera_icon', COM_createLink($camera_icon, $profileUrl)); } else { $article->set_var('contributedby_photo', ''); $article->set_var('author_photo', ''); $article->set_var('camera_icon', ''); } } $article->set_var('story_topic_id', $story->DisplayElements('tid')); $article->set_var('story_topic_name', $topicname); $article->set_var('story_topic_url', $topicurl); $recent_post_anchortag = ''; $article->set_var('lang_permalink', $LANG01[127]); $show_comments = true; // n = Full display of article. p = 'Preview' mode. if ($index != 'n' && $index != 'p' || !empty($query)) { $attributes = ' class="non-ul"'; $attr_array = array('class' => 'non-ul'); if (!empty($query)) { $attributes .= ' rel="bookmark"'; $attr_array['rel'] = 'bookmark'; } $article->set_var('start_storylink_anchortag', '<a href="' . $articleUrl . '"' . $attributes . '>'); $article->set_var('end_storylink_anchortag', '</a>'); $article->set_var('story_title_link', COM_createLink($story->DisplayElements('title'), $articleUrl, $attr_array)); } else { $article->set_var('story_title_link', $story->DisplayElements('title')); } $related_topics = ''; if ($index == 'n') { if ($_CONF['supported_version_theme'] == '1.8.1') { $article->set_var('breadcrumb_trail', TOPIC_breadcrumbs('article', $story->getSid())); } if ($_CONF['related_topics'] > 0) { $related_topics = TOPIC_relatedTopics('article', $story->getSid(), $_CONF['related_topics_max']); $article->set_var('related_topics', $related_topics); } } elseif ($index != 'p') { if ($_CONF['related_topics'] > 1) { $related_topics = TOPIC_relatedTopics('article', $story->getSid(), $_CONF['related_topics_max']); $article->set_var('related_topics', $related_topics); } } $page_selector = ''; $readmore_link = ''; $post_comment_link = ''; $plugin_itemdisplay = ''; $comments_with_count = ''; $trackbacks_with_count = ''; if ($index == 'n' || $index == 'p') { if (empty($bodytext)) { $article->set_var('story_introtext', $introtext); $article->set_var('story_text_no_br', $introtext); } else { if ($_CONF['allow_page_breaks'] == 1 && $index == 'n') { $story_page = 1; // page selector if (is_numeric($mode)) { $story_page = $mode; if ($story_page <= 0) { $story_page = 1; $mode = 0; } elseif ($story_page > 1) { $introtext = ''; } } $article_array = explode('[page_break]', $bodytext); $page_break_count = count($article_array); if ($story_page > $page_break_count) { // Can't have page count greater than actual number of pages $story_page = $page_break_count; } $page_selector = COM_printPageNavigation($articleUrl, $story_page, $page_break_count, 'mode=', $_CONF['url_rewrite'], $LANG01[118]); if (count($article_array) > 1) { $bodytext = $article_array[$story_page - 1]; } $article->set_var('page_selector', $page_selector); if ($_CONF['page_break_comments'] == 'last' && $story_page < count($article_array) || $_CONF['page_break_comments'] == 'first' && $story_page != 1) { $show_comments = false; } $article->set_var('story_page', $story_page); } $article->set_var('story_introtext', $introtext . '<br' . XHTML . '><br' . XHTML . '>' . $bodytext); $article->set_var('story_text_no_br', $introtext . ' ' . $bodytext); } $article->set_var('story_introtext_only', $introtext); $article->set_var('story_bodytext_only', $bodytext); if (($_CONF['trackback_enabled'] || $_CONF['pingback_enabled']) && SEC_hasRights('story.ping')) { $url = $_CONF['site_admin_url'] . '/trackback.php?mode=sendall&id=' . $story->getSid(); $article->set_var('send_trackback_link', COM_createLink($LANG_TRB['send_trackback'], $url)); $pingico = '<img src="' . $_CONF['layout_url'] . '/images/sendping.' . $_IMAGE_TYPE . '" alt="' . $LANG_TRB['send_trackback'] . '" title="' . $LANG_TRB['send_trackback'] . '"' . XHTML . '>'; $article->set_var('send_trackback_icon', COM_createLink($pingico, $url)); $article->set_var('send_trackback_url', $url); $article->set_var('lang_send_trackback_text', $LANG_TRB['send_trackback']); } $article->set_var('story_display', $index == 'p' ? 'preview' : 'article'); $article->set_var('story_counter', 0); } else { $article->set_var('story_introtext', $introtext); $article->set_var('story_text_no_br', $introtext); $article->set_var('story_introtext_only', $introtext); if ($readmore) { $article->set_var('lang_readmore', $LANG01[2]); $article->set_var('lang_readmore_words', $LANG01[62]); $article->set_var('readmore_words', $numwords); $readmore_link = COM_createLink($LANG01[2], $articleUrl, array('class' => 'story-read-more-link')) . ' (' . $numwords . ' ' . $LANG01[62] . ') '; $article->set_var('readmore_link', $readmore_link); $article->set_var('start_readmore_anchortag', '<a href="' . $articleUrl . '" class="story-read-more-link">'); $article->set_var('end_readmore_anchortag', '</a>'); $article->set_var('read_more_class', 'class="story-read-more-link"'); } if ($story->DisplayElements('commentcode') >= 0 && $show_comments) { $commentsUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid()) . '#comments'; $article->set_var('comments_url', $commentsUrl); $article->set_var('comments_text', COM_numberFormat($story->DisplayElements('comments')) . ' ' . $LANG01[3]); $article->set_var('comments_count', COM_numberFormat($story->DisplayElements('comments'))); $article->set_var('lang_comments', $LANG01[3]); $comments_with_count = sprintf($LANG01[121], COM_numberFormat($story->DisplayElements('comments'))); if ($story->DisplayElements('comments') > 0) { $result = DB_query("SELECT UNIX_TIMESTAMP(date) AS day,username,fullname,{$_TABLES['comments']}.uid as cuid FROM {$_TABLES['comments']},{$_TABLES['users']} WHERE {$_TABLES['users']}.uid = {$_TABLES['comments']}.uid AND sid = '" . $story->getSid() . "' ORDER BY date DESC LIMIT 1"); $C = DB_fetchArray($result); $recent_post_anchortag = '<span class="storybyline">' . $LANG01[27] . ': ' . strftime($_CONF['daytime'], $C['day']) . ' ' . $LANG01[104] . ' ' . COM_getDisplayName($C['cuid'], $C['username'], $C['fullname']) . '</span>'; $comments_with_count = COM_createLink($comments_with_count, $commentsUrl); $article->set_var('comments_with_count', $comments_with_count); $article->set_var('start_comments_anchortag', '<a href="' . $commentsUrl . '">'); $article->set_var('end_comments_anchortag', '</a>'); } else { $article->set_var('comments_with_count', $comments_with_count); if ($_CONF['comment_on_same_page'] == true) { $recent_post_anchortag = COM_createLink($LANG01[60], $_CONF['site_url'] . '/article.php?story=' . $story->getSid() . '#commenteditform'); } else { $recent_post_anchortag = COM_createLink($LANG01[60], $_CONF['site_url'] . '/comment.php?sid=' . $story->getSid() . '&pid=0&type=article'); if ($_CONF['show_comments_at_replying'] == true) { $recent_post_anchortag .= '#commenteditform'; } } } if ($story->DisplayElements('commentcode') == 0) { if ($_CONF['comment_on_same_page'] == true) { $postCommentUrl = $_CONF['site_url'] . '/article.php?story=' . $story->getSid() . '#commenteditform'; } else { $postCommentUrl = $_CONF['site_url'] . '/comment.php?sid=' . $story->getSid() . '&pid=0&type=article'; if ($_CONF['show_comments_at_replying'] == true) { $postCommentUrl .= '#commenteditform'; } } $post_comment_link = COM_createLink($LANG01[60], $postCommentUrl, array('rel' => 'nofollow')); $article->set_var('post_comment_link', $post_comment_link); /* $article->set_var( 'subscribe_link', COM_createLink('Nubbies', '', array('rel' => 'nofollow')) ); */ $article->set_var('lang_post_comment', $LANG01[60]); $article->set_var('start_post_comment_anchortag', '<a href="' . $postCommentUrl . '" rel="nofollow">'); $article->set_var('end_post_comment_anchortag', '</a>'); } } if (($_CONF['trackback_enabled'] || $_CONF['pingback_enabled']) && $story->DisplayElements('trackbackcode') >= 0 && $show_comments) { $num_trackbacks = COM_numberFormat($story->DisplayElements('trackbacks')); $trackbacksUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid()) . '#trackback'; $article->set_var('trackbacks_url', $trackbacksUrl); $article->set_var('trackbacks_text', $num_trackbacks . ' ' . $LANG_TRB['trackbacks']); $article->set_var('trackbacks_count', $num_trackbacks); $article->set_var('lang_trackbacks', $LANG_TRB['trackbacks']); if (SEC_hasRights('story.ping')) { $pingurl = $_CONF['site_admin_url'] . '/trackback.php?mode=sendall&id=' . $story->getSid(); $pingico = '<img src="' . $_CONF['layout_url'] . '/images/sendping.' . $_IMAGE_TYPE . '" alt="' . $LANG_TRB['send_trackback'] . '" title="' . $LANG_TRB['send_trackback'] . '"' . XHTML . '>'; $article->set_var('send_trackback_icon', COM_createLink($pingico, $pingurl)); } $trackbacks_with_count = sprintf($LANG01[122], $num_trackbacks); if ($story->DisplayElements('trackbacks') > 0) { $trackbacks_with_count = COM_createLink($trackbacks_with_count, $trackbacksUrl); } $article->set_var('trackbacks_with_count', $trackbacks_with_count); } if ($_CONF['hideemailicon'] == 1 || COM_isAnonUser() && ($_CONF['loginrequired'] == 1 || $_CONF['emailstoryloginrequired'] == 1)) { $article->set_var('email_icon', ''); } else { $emailUrl = $_CONF['site_url'] . '/profiles.php?sid=' . $story->getSid() . '&what=emailstory'; $emailicon = '<img src="' . $_CONF['layout_url'] . '/images/mail.' . $_IMAGE_TYPE . '" alt="' . $LANG01[64] . '" title="' . $LANG11[2] . '"' . XHTML . '>'; $article->set_var('email_icon', COM_createLink($emailicon, $emailUrl)); $article->set_var('email_story_url', $emailUrl); $article->set_var('lang_email_story', $LANG11[2]); $article->set_var('lang_email_story_alt', $LANG01[64]); } $printUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid() . '&mode=print'); if ($_CONF['hideprintericon'] == 1) { $article->set_var('print_icon', ''); } else { $printicon = '<img src="' . $_CONF['layout_url'] . '/images/print.' . $_IMAGE_TYPE . '" alt="' . $LANG01[65] . '" title="' . $LANG11[3] . '"' . XHTML . '>'; $article->set_var('print_icon', COM_createLink($printicon, $printUrl, array('rel' => 'nofollow'))); $article->set_var('print_story_url', $printUrl); $article->set_var('lang_print_story', $LANG11[3]); $article->set_var('lang_print_story_alt', $LANG01[65]); } $article->set_var('story_display', 'index'); $storyCounter++; $article->set_var('story_counter', $storyCounter); } $article->set_var('recent_post_anchortag', $recent_post_anchortag); if ($index != 'p' && SEC_hasRights('story.edit') && $story->checkAccess() == 3 && TOPIC_hasMultiTopicAccess('article', $story->DisplayElements('sid')) == 3) { $editUrl = $_CONF['site_admin_url'] . '/story.php?mode=edit&sid=' . $story->getSid(); $editiconhtml = '<img src="' . $_CONF['layout_url'] . '/images/edit.' . $_IMAGE_TYPE . '" alt="' . $LANG01[4] . '" title="' . $LANG01[4] . '"' . XHTML . '>'; $article->set_var('edit_link', COM_createLink($LANG01[4], $editUrl)); $article->set_var('edit_url', $editUrl); $article->set_var('lang_edit_text', $LANG01[4]); $article->set_var('edit_icon', COM_createLink($editiconhtml, $editUrl, array('class' => 'editlink'))); $article->set_var('edit_image', $editiconhtml); } $navi_list = true; $feedback_list = true; if ($index == 'p') { $navi_list = false; $feedback_list = false; } else { $navi_list = $page_selector !== '' || $readmore_link !== '' || $post_comment_link !== ''; $feedback_list = $plugin_itemdisplay !== '' || $comments_with_count !== '' || $trackbacks_with_count !== ''; } $story_footer = $navi_list || $feedback_list || $related_topics !== ''; $article->set_var('navi_list', $navi_list); $article->set_var('feedback_list', $feedback_list); $article->set_var('story_footer', $story_footer); if ($story->DisplayElements('featured') == 1) { $article->set_var('lang_todays_featured_article', $LANG05[4]); $article->parse('story_bodyhtml', 'featuredbodytext', true); PLG_templateSetVars('featuredstorytext', $article); } elseif ($story->DisplayElements('statuscode') == STORY_ARCHIVE_ON_EXPIRE && $story->DisplayElements('expire') <= time()) { $article->parse('story_bodyhtml', 'archivestorybodytext', true); PLG_templateSetVars('archivestorytext', $article); } else { $article->parse('story_bodyhtml', 'bodytext', true); PLG_templateSetVars('storytext', $article); } // Add related articles if ($index === 'n') { $article->set_var('related_articles_by_keyword', Story::getRelatedArticlesByKeywords($story->getSid(), $story->DisplayElements('meta_keywords'))); } PLG_templateSetVars($article_filevar, $article); if ($index != 'p' && ($cache_time > 0 || $cache_time == -1)) { $article->create_instance($cacheInstance, $article_filevar); // CACHE_create_instance($cacheInstance, $article); } } else { PLG_templateSetVars($article_filevar, $article); if (!$_CONF['cache_templates']) { // Hack (see Geeklog Bug Tracker issue #0001817): Cannot set the template variable directly with set_var since // this template variable was set with set_file which uses the templatecode array (set_var uses varvals array) // so have to update the templatecode array directly. This array really shouldn't be accessed this way // and this hack should be changed in the future: either set_var or set_file functions need to allow update of the file template variable found in templatecode // $article->set_var($article_filevar, $retval); $article->templateCode[$article_filevar] = $retval; } } $article->parse('finalstory', $article_filevar); return $article->finish($article->get_var('finalstory')); }
/** * Shows the plugin information center for uninstalled plugins * * @param string $pi_name Plugin name * @return string HTML for plugin editor form or error message * */ function plugin_info_uninstalled($pi_name) { global $_CONF, $_TABLES, $_USER, $LANG32, $LANG_ADMIN; $retval = ''; if (strlen($pi_name) == 0) { $retval .= COM_showMessageText($LANG32[12], $LANG32[13]); return $retval; } // Get data $params = PLG_getParams($pi_name); // Do template stuff $plg_templates = COM_newTemplate($_CONF['path_layout'] . 'admin/plugins'); $plg_templates->set_file('editor', 'info.thtml'); $plg_templates->set_var('start_block_editor', COM_startBlock('', '', COM_getBlockTemplate('_admin_block', 'header'))); $plg_templates->set_var('pi_icon', PLG_getIcon($pi_name)); $plg_templates->set_var('title', $LANG32[13]); $plg_templates->set_var('lang_pluginname', $LANG32[26]); $plg_templates->set_var('pi_display_name', plugin_get_pluginname($pi_name)); $plg_templates->set_var('lang_pluginversion', $LANG32[17]); $plg_templates->set_var('pi_version', $params['info']['pi_version']); $plg_templates->set_var('lang_pluginhomepage', $LANG32[27]); if (!empty($params['info']['pi_homepage'])) { $plg_templates->set_var('pi_homepage', COM_CreateLink($params['info']['pi_homepage'], $params['info']['pi_homepage'])); } else { $plg_templates->set_var('pi_homepage', $LANG_ADMIN['na']); } $pi_deps = PLG_printDependencies($pi_name, $params['info']['pi_gl_version']); $plg_templates->set_var('lang_dependencies', $LANG32[50]); $plg_templates->set_var('pi_dependencies', $pi_deps); $plg_templates->set_var('back', $LANG32[60]); $plg_templates->set_var('end_block', COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'))); $retval .= $plg_templates->finish($plg_templates->parse('output', 'editor')); return $retval; }
function MG_watermarkUploadSave() { global $_USER, $_CONF, $_TABLES, $_MG_CONF, $LANG_MG00, $LANG_MG01, $LANG_MG02, $LANG_MG03; // ok, we just check the type, we will accept png,jpg for now... $retval = '<h2>' . $LANG_MG03['upload_results'] . '</h2>'; $T = COM_newTemplate(MG_getTemplatePath(0)); $T->set_file('mupload', 'useruploadstatus.thtml'); $statusMsg = ''; $errors = 0; $file = array(); $file = $_FILES['newmedia']; $public = isset($_POST['wm_public']) ? COM_applyFilter($_POST['wm_public'], true) : 0; foreach ($file['name'] as $key => $name) { $filename = $file['name'][$key]; $filetype = $file['type'][$key]; $filesize = $file['size'][$key]; $filetmp = $file['tmp_name'][$key]; $error = $file['error'][$key]; $description = $_POST['description'][$key]; if ($filesize > 65536) { // right now we hard coded 64kb COM_errorLog("MG Upload: File " . $filename . " exceeds maximum allowed filesize for this album"); $tmpmsg = sprintf($LANG_MG02['upload_exceeds_max_filesize'], $filename); $statusMsg .= $tmpmsg . '<br' . XHTML . '>'; continue; } if ($error != UPLOAD_ERR_OK) { switch ($error) { case 1: $tmpmsg = sprintf($LANG_MG02['upload_too_big'], $filename); $statusMsg .= $tmpmsg . '<br' . XHTML . '>'; COM_errorLog('Media Gallery Error - ' . $tmpmsg); break; case 2: $tmpmsg = sprintf($LANG_MG02['upload_too_big_html'], $filename); $statusMsg .= $tmpmsg . '<br' . XHTML . '>'; COM_errorLog('Media Gallery Error - ' . $tmpmsg); break; case 3: $tmpmsg = sprintf($LANG_MG02['partial_upload'], $filename); $statusMsg .= $tmpmsg . '<br' . XHTML . '>'; COM_errorLog('Media Gallery Error - ' . $tmpmsg); break; case 4: $tmpmsg = $LANG_MG02['no_file_uploaded']; $statusMsg .= $tmpmsg . '<br' . XHTML . '>'; COM_errorLog('Media Gallery Error - ' . $tmpmsg); break; case 6: $statusMsg .= $LANG_MG02['missing_tmp'] . '<br' . XHTML . '>'; break; case 7: $statusMsg .= $LANG_MG02['disk_fail'] . '<br' . XHTML . '>'; break; default: $statusMsg .= $LANG_MG02['unknown_err'] . '<br' . XHTML . '>'; break; } continue; } $uid = $_USER['uid']; if ($public == 1) { $uid = 0; } //This will set the Content-Type to the appropriate setting for the file $file_extension = strtolower(substr(strrchr($filename, "."), 1)); switch ($file_extension) { case "png": $filetype = "image/png"; break; case "jpg": $filetype = "image/jpeg"; break; case "gif": $filetype = "image/gif"; break; default: $statusMsg .= $filename . $LANG_MG02['unsupported_wm_type']; continue; break; } $sql = "SELECT MAX(wm_id) + 1 AS nextwm_id FROM " . $_TABLES['mg_watermarks']; $result = DB_query($sql); $row = DB_fetchArray($result); $wm_id = $row['nextwm_id']; if ($wm_id < 1) { $wm_id = 1; } if ($wm_id == 0) { COM_errorLog("Media Gallery Error - Returned 0 as wm_id"); $wm_id = 1; } $wm_filename = $_MG_CONF['path_html'] . 'watermarks/' . $uid . '_' . $filename; if (file_exists($wm_filename)) { $statusMsg .= sprintf($LANG_MG02['wm_already_exists'], $filename); } else { $rc = move_uploaded_file($filetmp, $wm_filename); if ($rc != 1) { COM_errorLog("Media Upload - Error moving uploaded file....rc = " . $rc); $statusMsg .= sprintf($LANG_MG02['move_error'], $filename); } else { chmod($wm_filename, 0644); $media_title_safe = substr($description, 0, 254); if ($_MG_CONF['htmlallowed'] != 1) { $media_title = addslashes(htmlspecialchars(strip_tags(COM_checkWords(COM_killJS($media_title_safe))))); } else { $media_title = addslashes(htmlspecialchars(COM_checkHTML(COM_checkWords(COM_killJS($media_title_safe))))); } $saveFileName = addslashes($uid . '_' . $filename); $sql = "INSERT INTO {$_TABLES['mg_watermarks']} (wm_id,owner_id,filename,description)\n VALUES ({$wm_id},'{$uid}','{$saveFileName}','{$media_title}')"; DB_query($sql); if ($_MG_CONF['verbose']) { COM_errorLog("MG Upload: Updating Album information"); } if (DB_error()) { COM_errorLog("MediaGallery: Error inserting watermark data into database"); @unlink($wm_filename); $statusMsg .= $filename . " - " . DB_error(); } else { $statusMsg .= $filename . $LANG_MG02['wm_success']; } } } } $T->set_var('status_message', $statusMsg); $tmp = $_MG_CONF['site_url'] . '/admin.php?album_id=0&mode=wmmanage'; $redirect = sprintf($LANG_MG01['watermark_redirect'], $tmp); $T->set_var('redirect', $redirect); $retval .= $T->finish($T->parse('output', 'mupload')); return $retval; }
/** * Shows search form * * Shows advanced search page * * @author Tony Bibbs, tony AT geeklog DOT net * @return string HTML output for form * */ public function showForm() { global $_CONF, $_TABLES, $LANG09; $retval = ''; // Verify current user my use the search form if (!$this->_isFormAllowed()) { return SEC_loginRequiredForm(); } $retval .= COM_startBlock($LANG09[1], 'advancedsearch.html'); $searchform = COM_newTemplate($_CONF['path_layout'] . 'search'); $searchform->set_file(array('searchform' => 'searchform.thtml', 'authors' => 'searchauthors.thtml')); $searchform->set_var('search_intro', $LANG09[19]); $searchform->set_var('lang_keywords', $LANG09[2]); $searchform->set_var('lang_keytype', $LANG09[36]); $searchform->set_var('lang_date', $LANG09[20]); $searchform->set_var('lang_to', $LANG09[21]); $searchform->set_var('date_format', $LANG09[22]); $searchform->set_var('lang_topic', $LANG09[3]); $searchform->set_var('lang_all', $LANG09[4]); $searchform->set_var('topic_option_list', TOPIC_getTopicListSelect($this->_topic, 2, true)); $searchform->set_var('lang_type', $LANG09[5]); $searchform->set_var('lang_results', $LANG09[59]); $searchform->set_var('lang_per_page', $LANG09[60]); $searchform->set_var('lang_exact_phrase', $LANG09[43]); $searchform->set_var('lang_all_words', $LANG09[44]); $searchform->set_var('lang_any_word', $LANG09[45]); $searchform->set_var('lang_titles', $LANG09[69]); $escquery = htmlspecialchars($this->_query); $escquery = str_replace(array('{', '}'), array('{', '}'), $escquery); $searchform->set_var('query', $escquery); $searchform->set_var('datestart', $this->_dateStart); $searchform->set_var('dateend', $this->_dateEnd); if ($this->_titlesOnly) { $searchform->set_var('title_checked', ' checked="checked"'); } else { $searchform->set_var('title_checked', ''); } $phrase_selected = ''; $all_selected = ''; $any_selected = ''; if ($this->_keyType == 'phrase') { $phrase_selected = 'selected="selected"'; } else { if ($this->_keyType == 'all') { $all_selected = 'selected="selected"'; } else { if ($this->_keyType == 'any') { $any_selected = 'selected="selected"'; } } } $searchform->set_var('key_phrase_selected', $phrase_selected); $searchform->set_var('key_all_selected', $all_selected); $searchform->set_var('key_any_selected', $any_selected); $options = ''; $plugintypes = array('all' => $LANG09[4], 'stories' => $LANG09[6], 'comments' => $LANG09[7]); $plugintypes = array_merge($plugintypes, PLG_getSearchTypes()); // Generally I don't like to hardcode HTML but this seems easiest foreach ($plugintypes as $key => $val) { $options .= "<option value=\"{$key}\""; if ($this->_type == $key) { $options .= ' selected="selected"'; } $options .= ">{$val}</option>" . LB; } $searchform->set_var('plugin_types', $options); if ($_CONF['contributedbyline'] == 1) { $searchform->set_var('lang_authors', $LANG09[8]); $searchusers = array(); $result = DB_query("SELECT DISTINCT uid FROM {$_TABLES['comments']}"); while ($A = DB_fetchArray($result)) { $searchusers[$A['uid']] = $A['uid']; } $result = DB_query("SELECT DISTINCT uid FROM {$_TABLES['stories']} WHERE (date <= NOW()) AND (draft_flag = 0)"); while ($A = DB_fetchArray($result)) { $searchusers[$A['uid']] = $A['uid']; } $inlist = implode(',', $searchusers); if (!empty($inlist)) { $sql = "SELECT uid,username,fullname FROM {$_TABLES['users']} WHERE uid IN ({$inlist})"; if (isset($_CONF['show_fullname']) && $_CONF['show_fullname'] == 1) { /* Caveat: This will group all users with an emtpy fullname * together, so it's not exactly sorted by their * full name ... */ $sql .= ' ORDER BY fullname,username'; } else { $sql .= ' ORDER BY username'; } $result = DB_query($sql); $options = ''; while ($A = DB_fetchArray($result)) { $options .= '<option value="' . $A['uid'] . '"'; if ($A['uid'] == $this->_author) { $options .= ' selected="selected"'; } $options .= '>' . htmlspecialchars(COM_getDisplayName('', $A['username'], $A['fullname'])) . '</option>'; } $searchform->set_var('author_option_list', $options); $searchform->parse('author_form_element', 'authors', true); } else { $searchform->set_var('author_form_element', '<input type="hidden" name="author" value="0"' . XHTML . '>'); } } else { $searchform->set_var('author_form_element', '<input type="hidden" name="author" value="0"' . XHTML . '>'); } // Results per page $options = ''; $limits = explode(',', $_CONF['search_limits']); foreach ($limits as $limit) { $options .= "<option value=\"{$limit}\""; if ($_CONF['num_search_results'] == $limit) { $options .= ' selected="selected"'; } $options .= ">{$limit}</option>" . LB; } $searchform->set_var('search_limits', $options); $searchform->set_var('lang_search', $LANG09[10]); PLG_templateSetVars('search', $searchform); $searchform->parse('output', 'searchform'); $retval .= $searchform->finish($searchform->get_var('output')); $retval .= COM_endBlock(); return $retval; }
/** * Provide an interface to configure backups * * @return string HTML for configuration function */ function DBADMIN_configBackup() { global $_CONF, $_TABLES, $_VARS, $LANG_DB_BACKUP, $LANG_ADMIN, $_IMAGE_TYPE, $_SCRIPTS; $tablenames = $_TABLES; $included = ''; $excluded = ''; $retval = ''; $exclude_tables = @unserialize($_VARS['_dbback_exclude']); if (!is_array($exclude_tables)) { $exclude_tables = array(); } $menu_arr = array(array('url' => $_CONF['site_admin_url'] . '/database.php', 'text' => $LANG_DB_BACKUP['database_admin']), array('url' => $_CONF['site_admin_url'], 'text' => $LANG_ADMIN['admin_home'])); $T = COM_newTemplate($_CONF['path_layout'] . 'admin/dbadmin'); $T->set_file('page', 'dbbackupcfg.thtml'); $_SCRIPTS->setJavaScriptFile('move_users', '/javascript/moveusers.js'); $T->set_var('start_block', COM_startBlock($LANG_DB_BACKUP['database_admin'], '', COM_getBlockTemplate('_admin_block', 'header'))); $T->set_var('admin_menu', ADMIN_createMenu($menu_arr, $LANG_DB_BACKUP['config_instructions'], $_CONF['layout_url'] . '/images/icons/database.' . $_IMAGE_TYPE)); $include_tables = array_diff($tablenames, $exclude_tables); foreach ($include_tables as $key => $name) { $included .= "<option value=\"{$name}\">{$name}</option>\n"; } foreach ($exclude_tables as $key => $name) { $excluded .= "<option value=\"{$name}\">{$name}</option>\n"; } $T->set_var(array('lang_tables_to_backup' => $LANG_DB_BACKUP['tables_to_backup'], 'lang_include' => $LANG_DB_BACKUP['include'], 'lang_exclude' => $LANG_DB_BACKUP['exclude'], 'lang_save' => $LANG_ADMIN['save'], 'included_tables' => $included, 'excluded_tables' => $excluded)); $T->set_var('end_block', COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'))); $T->parse('output', 'page'); $retval .= $T->finish($T->get_var('output')); return $retval; }