/** * Here we do the work * * @param string $comment * @return int */ public function execute($comment) { global $_TABLES, $_USER, $LANG_SX00, $LANG28; $uid = COM_isAnonUser() ? 1 : $_USER['uid']; // Get homepage URLs of all banned users $result = DB_query("SELECT DISTINCT homepage FROM {$_TABLES['users']} WHERE status = 0 AND homepage IS NOT NULL AND homepage <> ''"); $numRows = DB_numRows($result); // named entities $comment = html_entity_decode($comment); // decimal notation $comment = preg_replace_callback('/&#(\\d+);/m', array($this, 'callbackDecimal'), $comment); // hex notation $comment = preg_replace_callback('/&#x([a-f0-9]+);/mi', array($this, 'callbackHex'), $comment); $ans = 0; for ($i = 0; $i < $numRows; $i++) { list($val) = DB_fetchArray($result); $val = str_replace('#', '\\#', $val); if (preg_match("#{$val}#i", $comment)) { $ans = 1; // quit on first positive match SPAMX_log($LANG_SX00['foundspam'] . $val . ' (' . $LANG28[42] . ')' . $LANG_SX00['foundspam2'] . $uid . $LANG_SX00['foundspam3'] . $_SERVER['REMOTE_ADDR']); break; } } $this->result = $ans; return $ans; }
function parse($p1, $p2 = '', $fulltag) { global $_CONF, $LANG01, $LANG04; $retval = ''; if (COM_isAnonUser()) { $options = array('hide_forgotpw_link' => false, 'form_action' => $_CONF['site_url'] . '/users.php'); $options['title'] = $LANG04[65]; // log in to {site_name} $options['message'] = $LANG04[66]; // please enter your user name and password below $retval .= '<div class="uk-navbar-content uk-navbar-flip uk-hidden-small">'; $retval .= '<button class="uk-button uk-button-success" type="button" data-uk-modal="{target:\'#modalOpen\'}">' . $LANG01[58] . '</button></div>'; $retval .= '<div id="modalOpen" class="uk-modal">'; $retval .= '<div class="uk-modal-dialog uk-modal-dialog-medium"><a href="#" class="uk-modal-close uk-close"></a>'; $retval .= SEC_loginForm($options); $retval .= '</div></div>'; } else { $retval .= '<ul class="uk-navbar-nav tm-navbar-nav uk-navbar-flip">'; $retval .= '<li class="uk-parent uk-hidden-small" data-uk-dropdown>'; $retval .= '<a href="#">My Account <i class="uk-icon-caret-down"></i></a>'; $retval .= '<div class="uk-dropdown tm-dropdown uk-dropdown-navbar">'; $retval .= '<ul class="uk-nav uk-nav-navbar tm-nav-navbar">'; $userMenu = getUserMenu(); foreach ($userMenu as $option) { $retval .= '<li><a href="' . $option['url'] . '">' . $option['label'] . '</a></li>'; } $retval .= '</ul></div></li></ul>'; } return $retval; }
/** * Shows all polls in system * * List all the polls on the system if no $pid is provided * * @return string HTML for poll listing * */ function POLLS_pollList() { global $_CONF, $_TABLES, $_USER, $_PO_CONF, $LANG25, $LANG_LOGIN, $LANG_POLLS; $retval = ''; if (COM_isAnonUser() && ($_CONF['loginrequired'] == 1 || $_PO_CONF['pollsloginrequired'] == 1)) { $retval .= SEC_loginRequiredForm(); } else { USES_lib_admin(); $header_arr = array(array('text' => $LANG25[9], 'field' => 'topic', 'sort' => true), array('text' => $LANG25[20], 'field' => 'voters', 'sort' => true, 'align' => 'center'), array('text' => $LANG25[3], 'field' => 'unixdate', 'sort' => true, 'align' => 'center'), array('text' => $LANG_POLLS['open_poll'], 'field' => 'is_open', 'sort' => true, 'align' => 'center')); $defsort_arr = array('field' => 'unixdate', 'direction' => 'desc'); $text_arr = array('has_menu' => false, 'title' => $LANG_POLLS['pollstitle'], 'instructions' => "", 'icon' => '', 'form_url' => ''); $query_arr = array('table' => 'polltopics', 'sql' => $sql = "SELECT *,UNIX_TIMESTAMP(date) AS unixdate, display " . "FROM {$_TABLES['polltopics']} WHERE 1=1", 'query_fields' => array('topic'), 'default_filter' => COM_getPermSQL(), 'query' => '', 'query_limit' => 0); $retval .= ADMIN_list('polls', 'POLLS_getListField', $header_arr, $text_arr, $query_arr, $defsort_arr, '', $token = 'dummy'); } return $retval; }
/** * Shows all polls in system * * List all the polls on the system if no $pid is provided * * @return string HTML for poll listing * */ function polllist() { global $_CONF, $_TABLES, $_PO_CONF, $LANG25, $LANG_POLLS; $retval = ''; if (COM_isAnonUser() && ($_CONF['loginrequired'] == 1 || $_PO_CONF['pollsloginrequired'] == 1)) { $retval .= SEC_loginRequiredForm(); } else { require_once $_CONF['path_system'] . 'lib-admin.php'; $header_arr = array(array('text' => $LANG25[9], 'field' => 'topic', 'sort' => true), array('text' => $LANG25[20], 'field' => 'voters', 'sort' => true), array('text' => $LANG25[3], 'field' => 'unixdate', 'sort' => true), array('text' => $LANG_POLLS['open_poll'], 'field' => 'is_open', 'sort' => true)); $defsort_arr = array('field' => 'unixdate', 'direction' => 'desc'); $text_arr = array('has_menu' => false, 'title' => $LANG_POLLS['pollstitle'], 'instructions' => "", 'icon' => '', 'form_url' => '', 'form_url' => $_CONF['site_url'] . '/polls/index.php'); $query_arr = array('table' => 'polltopics', 'sql' => $sql = "SELECT *,UNIX_TIMESTAMP(created) AS unixdate, display " . "FROM {$_TABLES['polltopics']} WHERE 1=1", 'query_fields' => array('topic'), 'default_filter' => COM_getPermSQL(), 'query' => '', 'query_limit' => 0); $retval .= ADMIN_list('polls', 'plugin_getListField_polls', $header_arr, $text_arr, $query_arr, $defsort_arr); } return $retval; }
function handleSubscribe($album_id) { global $_CONF, $_TABLES, $_USER, $MG_albums, $LANG_MG02; $referer = isset($_SERVER['HTTP_REFERER']) ? COM_sanitizeUrl($_SERVER['HTTP_REFERER']) : $_CONF['site_url']; if ($referer == '') { $referer = $_CONF['site_url']; } $sLength = strlen($_CONF['site_url']); if (substr($referer, 0, $sLength) != $_CONF['site_url']) { $referer = $_CONF['site_url']; } $hasargs = strstr($referer, '?'); if ($hasargs) { $sep = '&'; } else { $sep = '?'; } if (COM_isAnonUser()) { echo COM_refresh($referer . $sep . 'msg=518'); exit; } $errorMessage = ''; if (!isset($MG_albums[$album_id]->id)) { $errorMessage = $LANG_MG02['albumaccessdeny']; } else { if ($MG_albums[$album_id]->access == 0 || $MG_albums[$album_id]->hidden == 1 && $MG_albums[$album_id]->access != 3) { $errorMessage = $LANG_MG02['albumaccessdeny']; } } if (!empty($errorMessage)) { echo MG_siteHeader(); echo $errorMessage; echo MG_siteFooter(); exit; } $uid = $_USER['uid']; $id_desc = $MG_albums[$album_id]->title; $rc = PLG_subscribe('mediagallery', '', $album_id, $uid, '', $id_desc); if ($rc === false) { echo COM_refresh($referer . $sep . 'msg=519'); exit; } echo COM_refresh($referer . $sep . 'msg=520'); exit; }
/** * FTP Import * * @param int album_id album_id upload media * @return string HTML * */ function MG_ftpUpload($album_id) { global $MG_albums, $_USER, $_CONF, $_MG_CONF, $LANG_MG00, $LANG_MG01, $LANG_MG03; $retval = ''; $T = new Template(MG_getTemplatePath($album_id)); $T->set_file('mupload', 'ftpupload.thtml'); $T->set_var('site_url', $_CONF['site_url']); $T->set_var('album_id', $album_id); if ($MG_albums[$album_id]->access == 3 || SEC_hasRights('mediagallery.admin') || $MG_albums[$album_id]->member_uploads == 1 && !COM_isAnonUser()) { $T->set_var(array('s_form_action' => $_MG_CONF['site_url'] . '/admin.php', 'lang_upload_help' => $LANG_MG03['upload_help'], 'lang_media_ftp' => $LANG_MG01['upload_media'], 'lang_directory' => $LANG_MG01['directory'], 'lang_recurse' => $LANG_MG01['recurse'], 'lang_delete_files' => $LANG_MG01['delete_files'], 'lang_caption' => $LANG_MG01['caption'], 'lang_file' => $LANG_MG01['file'], 'lang_description' => $LANG_MG01['description'], 'lang_save' => $LANG_MG01['save'], 'lang_cancel' => $LANG_MG01['cancel'], 'lang_reset' => $LANG_MG01['reset'], 'lang_yes' => $LANG_MG01['yes'], 'lang_no' => $LANG_MG01['no'], 'lang_ftp_help' => $LANG_MG03['ftp_help'], 'album_id' => $album_id, 'ftp_path' => $_MG_CONF['ftp_path'], 'action' => 'ftp')); $T->parse('output', 'mupload'); $retval .= $T->finish($T->get_var('output')); return $retval; } else { COM_errorLog("MediaGallery: user attempted to upload to a restricted album."); return MG_genericError($LANG_MG00['access_denied_msg']); } }
/** * Check if user is authorized * * * @return boolean true if access granted, false if no access */ function auth() { global $_CONF, $REMOTE_ADDR; $urlfor = 'advancededitor'; if (COM_isAnonUser()) { $urlfor = 'advancededitor' . md5($REMOTE_ADDR); } $cookiename = $_CONF['cookie_name'] . 'adveditor'; if (isset($_COOKIE[$cookiename])) { $token = $_COOKIE[$cookiename]; } else { $token = ''; } if (SEC_checkTokenGeneral($token, $urlfor)) { return true; } else { return false; } return false; }
/** * Plugin function to display a specific comment thread * $id Unique idenifier for item comment belongs to * $cid Comment id to display (possibly including sub-comments) * $title Page/comment title * $order 'ASC' or 'DSC' or blank * $format 'threaded', 'nested', or 'flat' * $page Page number of comments to display * $view True to view comment (by cid), false to display (by $pid) */ function _mg_displaycomment($id, $commentid, $title, $order, $format, $page, $view) { global $_CONF, $_USER, $_MG_CONF, $LANG_LOGIN; if (COM_isAnonUser() && $_MG_CONF['loginrequired']) { echo SEC_loginRequiredForm(); exit; } $retval = ''; require_once $_CONF['path'] . 'plugins/mediagallery/include/classAlbum.php'; require_once $_CONF['path'] . 'plugins/mediagallery/include/lib-media.php'; list($ptitle, $retval, $themeCSS, $album_id) = MG_displayMediaImage($id, 0, 0, 0); $retval = $themeCSS . $retval; if (SEC_hasRights('mediagallery.admin')) { $delete_option = true; } else { $delete_option = false; } $view = $view == 1 ? true : false; $retval .= CMT_userComments($id, $title, 'mediagallery', $order, $format, $commentid, $page, $view, $delete_option); return $retval; }
/** * 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; }
/** * 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 displayThumb($s, $sortOrder, $force = 0) { global $_USER, $_CONF, $_MG_CONF, $MG_albums, $_TABLES, $_MG_USERPREFS, $LANG_MG03, $LANG_MG01, $glversion, $ratedIds; $retval = ''; $T = new Template(MG_getTemplatePath($this->album_id)); if ($MG_albums[$this->album_id]->display_columns == 1) { $media_cell_image_template = 'album_page_body_media_cell_1.thtml'; } else { $media_cell_image_template = 'album_page_body_media_cell.thtml'; } if ($force) { $media_cell_image_template = 'album_page_body_media_cell.thtml'; } $T->set_file(array('media_cell_image' => $media_cell_image_template, 'media_rate_results' => 'album_page_body_media_cell_rating.thtml', 'media_comments' => 'album_page_body_media_cell_comment.thtml', 'media_views' => 'album_page_body_media_cell_view.thtml', 'media_cell_keywords' => 'album_page_body_media_cell_keywords.thtml', 'mp3_podcast' => 'mp3_podcast.thtml')); $F = new Template($_MG_CONF['template_path']); $F->set_var('media_frame', $MG_albums[$this->album_id]->imageFrameTemplate); // --- set the default thumbnail switch ($this->type) { case 0: // standard image $default_thumbnail = 'tn/' . $this->filename[0] . '/' . $this->filename . '.' . $this->mime_ext; if (!file_exists($_MG_CONF['path_mediaobjects'] . $default_thumbnail)) { $default_thumbnail = 'tn/' . $this->filename[0] . '/' . $this->filename . '.jpg'; } break; case 1: // video file switch ($this->mime_type) { case 'video/x-flv': $default_thumbnail = 'placeholder_flv.svg'; break; case 'application/x-shockwave-flash': $default_thumbnail = 'placeholder_flash.svg'; break; case 'video/mpeg': case 'video/x-mpeg': case 'video/x-mpeq2a': if ($_MG_CONF['use_wmp_mpeg'] == 1) { $default_thumbnail = 'placeholder_video.svg'; break; } case 'video/x-motion-jpeg': case 'video/quicktime': case 'video/x-qtc': case 'audio/mpeg': case 'video/x-m4v': $default_thumbnail = 'placeholder_quicktime.svg'; break; case 'asf': case 'video/x-ms-asf': case 'video/x-ms-asf-plugin': case 'video/avi': case 'video/msvideo': case 'video/x-msvideo': case 'video/avs-video': case 'video/x-ms-wmv': case 'video/x-ms-wvx': case 'video/x-ms-wm': case 'application/x-troff-msvideo': case 'application/x-ms-wmz': case 'application/x-ms-wmd': $default_thumbnail = 'placeholder_video.svg'; break; default: $default_thumbnail = 'placeholder_video.svg'; break; } break; case 2: // music file $default_thumbnail = 'placeholder_audio.svg'; break; case 4: // other files switch ($this->mime_type) { case 'application/zip': case 'zip': case 'arj': case 'rar': case 'gz': $default_thumbnail = 'zip.png'; break; case 'pdf': case 'application/pdf': $default_thumbnail = 'placeholder_pdf.svg'; break; default: if (isset($_MG_CONF['dt'][$this->mime_ext])) { $default_thumbnail = $_MG_CONF['dt'][$this->mime_ext]; } else { switch ($this->mime_ext) { case 'pdf': $default_thumbnail = 'placeholder_pdf.svg'; break; case 'arj': $default_thumbnail = 'zip.png'; break; case 'gz': $default_thumbnail = 'zip.png'; break; default: $default_thumbnail = 'generic.png'; break; } } break; } break; case 5: case 'embed': if (preg_match("/youtube/i", $this->remote_url)) { $default_thumbnail = 'youtube.png'; } else { if (preg_match("/google/i", $this->remote_url)) { $default_thumbnail = 'googlevideo.png'; } else { $default_thumbnail = 'remote.png'; } } break; } if ($this->tn_attached == 1) { $media_thumbnail = $_MG_CONF['mediaobjects_url'] . '/' . $default_thumbnail; $media_thumbnail_file = $_MG_CONF['path_mediaobjects'] . $default_thumbnail; foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $this->filename[0] . '/tn_' . $this->filename . $ext)) { $media_thumbnail = $_MG_CONF['mediaobjects_url'] . '/tn/' . $this->filename[0] . '/tn_' . $this->filename . $ext; $media_thumbnail_file = $_MG_CONF['path_mediaobjects'] . 'tn/' . $this->filename[0] . '/tn_' . $this->filename . $ext; break; } } } else { $media_thumbnail = $_MG_CONF['mediaobjects_url'] . '/' . $default_thumbnail; $media_thumbnail_file = $_MG_CONF['path_mediaobjects'] . $default_thumbnail; } // type == 1 video // type == 2 audio if (($this->type == 1 || $this->type == 2 || $this->type == 5) && ($MG_albums[$this->album_id]->playback_type == 0 || $MG_albums[$this->album_id]->playback_type == 1) && $_MG_CONF['popup_from_album'] == 1) { if ($MG_albums[$this->album_id]->playback_type == 0) { if ($this->type == 2) { // determine what type of player we will use (WMP, QT or Flash) $player = $_MG_CONF['mp3_player']; if (isset($_MG_USERPREFS['mp3_player']) && $_MG_USERPREFS['mp3_player'] != -1) { $player = $_MG_USERPREFS['mp3_player']; } switch ($player) { case 0: // WMP $new_y = 260; $new_x = 340; break; case 1: // QT $new_y = 25; $new_x = 350; break; case 2: $new_y = 360; $new_x = 580; break; } if ($this->mime_type == 'audio/mpeg') { $new_y = 360; $new_x = 580; } if ($this->tn_attached == 1 && $player != 2) { $tnsize = @getimagesize($media_thumbnail_file); $new_y += $tnsize[0]; if ($tnsize[1] > $new_x) { $new_x = $tnsize[1]; } } if ($MG_albums[$this->album_id]->playback_type == 0) { $url_display_item = "javascript:showVideo('" . $_MG_CONF['site_url'] . '/video.php?n=' . $this->id . "'," . $new_y . ',' . $new_x . ')'; } else { $url_display_item = $_MG_CONF['site_url'] . '/download.php?mid=' . $this->id; } $resolution_x = $new_x; $resolution_y = $new_y; } else { // must be a video... // set the default playback options... $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']; $playback_options['flashvars'] = $_MG_CONF['swf_flashvars']; $poResult = DB_query("SELECT * FROM {$_TABLES['mg_playback_options']} WHERE media_id='" . DB_escapeString($this->id) . "'"); while ($poRow = DB_fetchArray($poResult)) { $playback_options[$poRow['option_name']] = $poRow['option_value']; } if ($this->resolution_x > 0) { $resolution_x = $this->resolution_x; $resolution_y = $this->resolution_y; } else { if ($this->media_resolution_x == 0 && $this->remote_media != 1) { $size = @filesize($_MG_CONF['path_mediaobjects'] . 'orig/' . $this->filename[0] . '/' . $this->filename . '.' . $this->mime_ext); // skip files over 8M in size.. if ($size < 8388608) { $ThisFileInfo = IMG_getMediaMetaData($_MG_CONF['path_mediaobjects'] . 'orig/' . $this->filename[0] . '/' . $this->filename . '.' . $this->mime_ext); if ($ThisFileInfo['video']['resolution_x'] < 1 || $ThisFileInfo['video']['resolution_y'] < 1) { if (isset($ThisFileInfo['meta']['onMetaData']['width']) && isset($ThisFileInfo['meta']['onMetaData']['height'])) { $resolution_x = $ThisFileInfo['meta']['onMetaData']['width']; $resolution_y = $ThisFileInfo['meta']['onMetaData']['height']; } else { $resolution_x = -1; $resolution_y = -1; } } else { $resolution_x = $ThisFileInfo['video']['resolution_x']; $resolution_y = $ThisFileInfo['video']['resolution_y']; } if ($resolution_x != 0) { $sql = "UPDATE " . $_TABLES['mg_media'] . " SET media_resolution_x=" . intval($resolution_x) . ",media_resolution_y=" . intval($resolution_y) . " WHERE media_id='" . DB_escapeString($this->id) . "'"; DB_query($sql, 1); } } } else { $resolution_x = $this->resolution_x; $resolution_y = $this->resolution_y; } } $resolution_x = $playback_options['width']; $resolution_y = $playback_options['height']; if ($resolution_x < 1 || $resolution_y < 1) { $resolution_x = 480; $resolution_y = 320; } else { $resolution_x = $resolution_x + 40; $resolution_y = $resolution_y + 40; } if ($this->mime_type == 'video/x-flv' && $_MG_CONF['use_flowplayer'] != 1) { $resolution_x = $resolution_x + 60; if ($resolution_x < 590) { $resolution_x = 590; } $resolution_y = $resolution_y + 80; if ($resolution_y < 500) { $resolution_y = 500; } } if ($this->type == 5) { $resolution_x = 460; $resolution_y = 380; } $url_display_item = "javascript:showVideo('" . $_MG_CONF['site_url'] . '/video.php?n=' . $this->id . "'," . $resolution_y . ',' . $resolution_x . ')'; } } else { $url_display_item = $_MG_CONF['site_url'] . '/download.php?mid=' . $this->id; } // check to see if comments and rating are enabled, if not, put a link to edit... if ($MG_albums[$this->album_id]->access == 3) { $T->set_var(array('edit_link' => '<br/><a href="' . $_MG_CONF['site_url'] . '/admin.php?mode=mediaedit&s=1&album_id=' . $this->album_id . '&mid=' . $this->id . '">' . $LANG_MG01['edit'] . '</a>')); } else { $T->set_var(array('edit_link' => '')); } } else { if ($MG_albums[$this->album_id]->useAlternate == 1 && $this->type != 5 && !empty($this->remote_url)) { $url_display_item = $this->remote_url; } else { $url_display_item = $_MG_CONF['site_url'] . '/media.php?f=0' . '&sort=' . $sortOrder . '&s=' . $this->id; } } if ($this->type == 4) { // other $url_display_item = $_MG_CONF['site_url'] . '/download.php?mid=' . $this->id; } if (strstr($media_thumbnail_file, '.svg')) { $media_size = array($MG_albums[$this->album_id]->tnWidth, $MG_albums[$this->album_id]->tnHeight); } else { $media_size = @getimagesize($media_thumbnail_file); } if ($media_size == false) { if ($this->type == 2) { $default_thumbnail = 'placeholder_audio.svg'; } else { $default_thumbnail = 'placeholder.svg'; } $media_thumbnail = $_MG_CONF['mediaobjects_url'] . '/' . $default_thumbnail; $media_thumbnail_file = $_MG_CONF['path_mediaobjects'] . $default_thumbnail; $media_size = array($tn_width, $tn_height); //@getimagesize($media_thumbnail_file); } $media_time = MG_getUserDateTimeFormat($this->time); $upload_time = MG_getUserDateTimeFormat($this->upload_time); $url_media_item = $url_display_item; // -- decide what thumbnail size to use, small, medium, large... if (isset($_MG_USERPREFS['tn_size']) && $_MG_USERPREFS['tn_size'] != -1) { $tn_size = $_MG_USERPREFS['tn_size']; } else { $tn_size = $MG_albums[$this->album_id]->tn_size; } switch ($tn_size) { case '0': //small $tn_height = 100; $tn_width = 100; break; case '1': //medium $tn_height = 150; $tn_width = 150; break; case '2': $tn_height = 200; $tn_width = 200; break; case '3': case '4': $tn_height = $MG_albums[$this->album_id]->tnHeight; $tn_width = $MG_albums[$this->album_id]->tnWidth; if ($tn_height == 0) { $tn_height = 200; } if ($tn_width == 0) { $tn_width = 200; } break; default: $tn_height = 150; $tn_width = 150; break; } if ($media_size[0] > $media_size[1]) { // landscape $ratio = $media_size[0] / $tn_width; $newwidth = $tn_width; $newheight = round($media_size[1] / $ratio); } else { $ratio = $media_size[1] / $tn_height; if ($ratio == 0) { $newheight = $tn_height; $newwidth = $tn_width; } else { $newheight = $tn_height; $newwidth = round($media_size[0] / $ratio); } } if ($media_size[0] > $media_size[1]) { $ratio = $media_size[0] / 50; $smallwidth = 50; $smallheight = round($media_size[1] / $ratio); } else { $ratio = $media_size[1] / 50; if ($ratio == 0) { $smallheight = 50; $smallwidth = 50; } else { $smallheight = 50; $smallwidth = round($media_size[0] / $ratio); } } if ($this->owner_id != "" && $this->owner_id > 1) { $username = DB_getItem($_TABLES['users'], 'username', "uid=" . intval($this->owner_id)); } else { $username = '******'; } if (!isset($resolution_x)) { $resolution_x = $newwidth; } if (!isset($resolution_y)) { $resolution_y = $newheight; } if ($this->mime_type == 'audio/mpeg' && $MG_albums[$this->album_id]->mp3ribbon) { $T->set_var(array('mp3_file' => $_MG_CONF['mediaobjects_url'] . '/orig/' . $this->filename[0] . '/' . $this->filename . '.' . $this->mime_ext, 'site_url' => $_MG_CONF['site_url'], 'id' => $this->mime_ext . rand())); $T->parse('mp3_podcast', 'mp3_podcast'); } else { $T->set_var(array('mp3_podcast' => '')); } /* * build the small rating bar * */ if ($MG_albums[$this->album_id]->enable_rating > 0) { $uid = COM_isAnonUser() ? 1 : $_USER['uid']; $static = false; // check to see if we are the owner, if so, no rating for us... if (isset($_USER['uid']) && $_USER['uid'] == $this->owner_id) { $static = true; $voted = 0; } else { if (in_array($this->id, $ratedIds)) { $static = true; $voted = 1; } else { $static = 0; $voted = 0; } } if ($MG_albums[$this->album_id]->enable_rating == 1 && COM_isAnonUser()) { $static = true; } if ($_MG_CONF['use_large_stars'] == 1) { $starSize = ''; } else { $starSize = 'sm'; } $rating_box = RATING_ratingBar('mediagallery', $this->id, $this->votes, $this->rating, $voted, 5, $static, $starSize); } else { $rating_box = ''; } $T->set_var('rating_box', '<center>' . $rating_box . '</center>'); $fs_bytes = @filesize($_MG_CONF['path_mediaobjects'] . 'orig/' . $this->filename[0] . '/' . $this->filename . '.' . $this->mime_ext); $fileSize = MG_get_size($fs_bytes); $direct_url = 'disp/' . $this->filename[0] . '/' . $this->filename . '.' . $this->mime_ext; if (!file_exists($_MG_CONF['path_mediaobjects'] . $direct_url)) { $direct_url = 'disp/' . $this->filename[0] . '/' . $this->filename . '.jpg'; } if ($MG_albums[$this->album_id]->access == 3) { $edit_item = '<a href="' . $_MG_CONF['site_url'] . '/admin.php?mode=mediaedit&s=1&album_id=' . $this->album_id . '&mid=' . $this->id . '">' . $LANG_MG01['edit'] . '</a>'; } else { $edit_item = ''; } $L = new Template(MG_getTemplatePath($this->album_id)); $L->set_file('media_link', 'medialink.thtml'); $L->set_var('href', $url_media_item); if ($this->type == 0) { if ($this->remote == 1) { $L->set_var('hrefdirect', $this->remote_url); } else { $L->set_var('hrefdirect', $_MG_CONF['mediaobjects_url'] . '/' . $direct_url); } } $caption = PLG_replaceTags(str_replace('$', '$', $this->title), 'mediagallery', 'media_description'); if ($this->owner_id == $_USER['uid'] || SEC_hasRights('mediagallery.admin')) { $caption .= '<br />(' . $this->id . ')'; } $L->set_var('caption', $caption); $L->set_var('id', 'id' . rand()); $L->parse('media_link_start', 'media_link'); $media_start_link = $L->finish($L->get_var('media_link_start')); $T->set_var(array('play_now' => '', 'download_now' => $_MG_CONF['site_url'] . '/download.php?mid=' . $this->id, 'play_in_popup' => "javascript:showVideo('" . $_MG_CONF['site_url'] . '/video.php?n=' . $this->id . "'," . $resolution_y . ',' . $resolution_x . ')', 'row_height' => $tn_height + 40, 'media_title' => PLG_replaceTags($this->title, 'mediagallery', 'media_title'), 'media_description' => PLG_replaceTags(nl2br($this->description), 'mediagallery', 'media_description'), 'media_tag' => strip_tags($this->title), 'media_time' => $media_time[0], 'upload_time' => $upload_time[0], 'media_owner' => $username, 'site_url' => $_MG_CONF['site_url'], 'lang_published' => $LANG_MG03['published'], 'lang_on' => $LANG_MG03['on'], 'lang_hyphen' => $this->album == '' ? '' : '-', 'media_link_start' => $media_start_link, 'media_link_end' => '</a>', 'artist' => $this->artist, 'musicalbum' => $this->album != '' ? $this->album : '', 'genre' => $this->genre != '' ? $this->genre : '', 'alt_edit_link' => $edit_item, 'filesize' => $fileSize, 'media_id' => $this->id, 'raw_media_thumbnail' => $media_thumbnail, 'display_url' => $url_media_item)); // frame template variables $F->set_var(array('media_id' => $this->id, 'media_link_start' => $media_start_link, 'media_link_end' => '</a>', 'url_media_item' => $url_media_item, 'url_display_item' => $url_display_item, 'media_thumbnail' => $media_thumbnail, 'media_size' => 'width="' . $newwidth . '" height="' . $newheight . '"', 'media_height' => $newheight, 'media_width' => $newwidth, 'border_width' => $newwidth + 15, 'border_height' => $newheight + 15, 'row_height' => $tn_height + 40, 'frWidth' => $newwidth - $MG_albums[$this->album_id]->frWidth, 'frHeight' => $newheight - $MG_albums[$this->album_id]->frHeight, 'media_tag' => strip_tags($this->description), 'filesize' => $fileSize)); $F->parse('media', 'media_frame'); $media_item_thumbnail = $F->finish($F->get_var('media')); $T->set_var(array('media_item_thumbnail' => $media_item_thumbnail, 'url_media_item' => $url_media_item, 'url_display_item' => $url_display_item, 'media_thumbnail' => $media_thumbnail, 'media_size' => 'width="' . $newwidth . '" height="' . $newheight . '"')); if ($MG_albums[$this->album_id]->enable_keywords) { if (!empty($this->keywords)) { $kwText = ''; $keyWords = array(); $keyWords = explode(' ', $this->keywords); $numKeyWords = count($keyWords); for ($i = 0; $i < $numKeyWords; $i++) { $keyWords[$i] = str_replace('"', ' ', $keyWords[$i]); $searchKeyword = $keyWords[$i]; $keyWords[$i] = str_replace('_', ' ', $keyWords[$i]); $kwText .= '<a href="' . $_MG_CONF['site_url'] . '/search.php?mode=search&swhere=1&keywords=' . $searchKeyword . '&keyType=any">' . $keyWords[$i] . '</a> '; } $T->set_var(array('media_keywords' => $kwText, 'lang_keywords' => $LANG_MG01['keywords'])); $T->parse('media_cell_keywords', 'media_cell_keywords'); } else { $T->set_var('lang_keywords', ''); } } else { $T->set_var(array('media_cell_keywords' => '', 'lang_keywords' => '')); } if ($MG_albums[$this->album_id]->enable_rating) { $rating = $LANG_MG03['rating'] . ': <strong> ' . $this->rating / 2 . '</strong>/5 (' . $this->votes . ' ' . $LANG_MG03['votes'] . ')'; $T->set_var('media_rating', $rating); $T->parse('media_rate_results', 'media_rate_results'); } if ($MG_albums[$this->album_id]->enable_comments) { if ($this->type == 4 || $this->type == 1 && $MG_albums[$this->album_id]->playback_type != 2 || $this->type == 2 && $MG_albums[$this->album_id]->playback_type != 2 || $this->type == 5 && $MG_albums[$this->album_id]->playback_type != 2) { $cmtLink = '<a href="' . $_MG_CONF['site_url'] . '/media.php?f=0' . '&sort=' . $sortOrder . '&s=' . $this->id . '">' . $LANG_MG03['comments'] . '</a>'; $cmtLink_alt = ''; } else { $cmtLink = $LANG_MG03['comments']; $cmtLink_alt = '<a href="' . $_MG_CONF['site_url'] . '/media.php?f=0' . '&sort=' . $sortOrder . '&s=' . $this->id . '">' . $LANG_MG03['comments'] . '</a>'; } $T->set_var(array('media_comments_count' => $this->comments, 'lang_comments' => $cmtLink, 'lang_comments_hot' => $cmtLink_alt)); $T->parse('media_comments', 'media_comments'); } if ($MG_albums[$this->album_id]->enable_views) { $T->set_var(array('media_views_count' => $this->views, 'lang_views' => $LANG_MG03['views'])); $T->parse('media_views', 'media_views'); } $T->set_var(array('max-width' => $tn_width)); PLG_templateSetVars('mediagallery', $T); $T->parse('media_cell', 'media_cell_image'); $retval = $T->finish($T->get_var('media_cell')); return $retval; }
/** * Get the RSS feed links only * * @return array Array of links & titles */ function EVLIST_getFeedLinks() { global $_EV_CONF, $_TABLES; $retval = array(); if (COM_isAnonUser() && $_EV_CONF['allow_anon_view'] != 1) { return $retval; } // Get the feed info for configured feeds $result = DB_query("SELECT title, filename \n FROM {$_TABLES['syndication']}\n WHERE type='" . DB_escapeString($_EV_CONF['pi_name']) . "'"); if (DB_numRows($result) > 0) { $feed_url = SYND_getFeedUrl(); while ($A = DB_fetchArray($result, false)) { $retval[] = array('feed_title' => $A['title'], 'feed_url' => $feed_url . $A['filename']); } } return $retval; }
function MG_searchDisplayThumb($M, $sortOrder, $id, $page, $force = 0) { global $_CONF, $_USER, $_MG_CONF, $MG_albums, $_TABLES, $_MG_USERPREFS, $LANG_MG03, $LANG_MG01, $ratedIds; $playback_type = $_MG_CONF['search_playback_type']; $retval = ''; $nFrame = new mgFrame(); $nFrame->constructor('mgShadow'); $imageFrameTemplate = $nFrame->getTemplate(); $frWidth = $nFrame->frame['wHL'] + $nFrame->frame['wHR']; $frHeight = $nFrame->frame['hVT'] + $nFrame->frame['hVB']; $T = new Template(MG_getTemplatePath(0)); $T->set_file(array('media_cell_image' => 'album_page_body_media_cell.thtml', 'media_rate_results' => 'album_page_body_media_cell_rating.thtml', 'media_comments' => 'album_page_body_media_cell_comment.thtml', 'media_views' => 'album_page_body_media_cell_view.thtml', 'media_cell_keywords' => 'album_page_body_media_cell_keywords.thtml', 'mp3_podcast' => 'mp3_podcast.thtml')); $F = new Template($_MG_CONF['template_path']); $F->set_var('media_frame', $imageFrameTemplate); //$MG_albums[0]->imageFrameTemplate); // --- set the default thumbnail $default_thumbnail = 'generic.png'; switch ($M['media_type']) { case 0: // standard image foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $M['media_filename'][0] . '/' . $M['media_filename'] . $ext)) { $default_thumbnail = 'tn/' . $M['media_filename'][0] . '/' . $M['media_filename'] . $ext; break; } } break; case 1: // video file switch ($M['mime_type']) { case 'video/x-flv': $default_thumbnail = 'flv.png'; break; case 'application/x-shockwave-flash': $default_thumbnail = 'flash.png'; break; case 'video/mpeg': case 'video/x-mpeg': case 'video/x-mpeq2a': if ($_MG_CONF['use_wmp_mpeg'] == 1) { $default_thumbnail = 'wmp.png'; break; } case 'video/x-motion-jpeg': case 'video/quicktime': case 'video/x-qtc': case 'audio/mpeg': $default_thumbnail = 'quicktime.png'; break; case 'asf': case 'video/x-ms-asf': case 'video/x-ms-asf-plugin': case 'video/avi': case 'video/msvideo': case 'video/x-msvideo': case 'video/avs-video': case 'video/x-ms-wmv': case 'video/x-ms-wvx': case 'video/x-ms-wm': case 'application/x-troff-msvideo': case 'application/x-ms-wmz': case 'application/x-ms-wmd': $default_thumbnail = 'wmp.png'; break; default: $default_thumbnail = 'video.png'; break; } break; case 2: // music file $default_thumbnail = 'audio.png'; break; case 4: // other files switch ($M['mime_type']) { case 'application/zip': case 'zip': case 'arj': case 'rar': case 'gz': $default_thumbnail = 'zip.png'; break; case 'pdf': case 'application/pdf': $default_thumbnail = 'pdf.png'; break; default: switch ($M['media_mime_ext']) { case 'pdf': $default_thumbnail = 'pdf.png'; break; case 'arj': $default_thumbnail = 'zip.png'; break; case 'gz': $default_thumbnail = 'zip.png'; break; default: $default_thumbnail = 'generic.png'; break; } break; } break; case 5: case 'embed': if (preg_match("/youtube/i", $M['remote_url'])) { $default_thumbnail = 'youtube.png'; } else { if (preg_match("/google/i", $M['remote_url'])) { $default_thumbnail = 'googlevideo.png'; } else { $default_thumbnail = 'remote.png'; } } break; } if ($M['media_tn_attached'] == 1) { $media_thumbnail_file = ''; foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $M['media_filename'][0] . '/tn_' . $M['media_filename'] . $ext)) { $media_thumbnail = $_MG_CONF['mediaobjects_url'] . '/tn/' . $M['media_filename'][0] . '/tn_' . $M['media_filename'] . $ext; $media_thumbnail_file = $_MG_CONF['path_mediaobjects'] . 'tn/' . $M['media_filename'][0] . '/tn_' . $M['media_filename'] . $ext; break; } } if ($media_thumbnail_file == '') { $media_thumbnail = $_MG_CONF['mediaobjects_url'] . '/' . $default_thumbnail; $media_thumbnail_file = $_MG_CONF['path_mediaobjects'] . $default_thumbnail; } } else { $media_thumbnail = $_MG_CONF['mediaobjects_url'] . '/' . $default_thumbnail; $media_thumbnail_file = $_MG_CONF['path_mediaobjects'] . $default_thumbnail; } $resolution_x = 0; $resolution_y = 0; // type == 1 video // type == 2 audio if (($M['media_type'] == 1 || $M['media_type'] == 2 || $M['media_type'] == 5) && ($playback_type == 0 || $playback_type == 1)) { if ($playback_type == 0 || $playback_type == 1) { if ($M['media_type'] == 2) { // determine what type of player we will use (WMP, QT or Flash) $player = $_MG_CONF['mp3_player']; if (isset($_MG_USERPREFS['mp3_player']) && $_MG_USERPREFS['mp3_player'] != -1) { $player = $_MG_USERPREFS['mp3_player']; } switch ($player) { case 0: // WMP $new_y = 60; $new_x = 350; break; case 1: // QT $new_y = 25; $new_x = 350; break; case 2: $new_y = 360; $new_x = 580; break; } if ($M['media_tn_attached'] == 1 && $player != 2) { $tnsize = @getimagesize($media_thumbnail_file); $new_y += $tnsize[0]; if ($tnsize[1] > $new_x) { $new_x = $tnsize[1]; } } if ($playback_type == 0) { $url_display_item = "javascript:showVideo('" . $_MG_CONF['site_url'] . '/video.php?n=' . $M['media_id'] . "'," . $new_y . ',' . $new_x . ')'; } else { $url_display_item = $_MG_CONF['site_url'] . '/download.php?mid=' . $MG_media->id; } $resolution_x = $new_x; $resolution_y = $new_y; } else { // must be a video... // set the default playback options... $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']; $playback_options['flashvars'] = $_MG_CONF['swf_flashvars']; $poResult = DB_query("SELECT * FROM {$_TABLES['mg_playback_options']} WHERE media_id='" . DB_escapeString($M['media_id']) . "'"); while ($poRow = DB_fetchArray($poResult)) { $playback_options[$poRow['option_name']] = $poRow['option_value']; } if (isset($M['media_resolution_x']) && $M['media_resolution_x'] > 0) { $resolution_x = $M['media_resolution_x']; $resolution_y = $M['media_resolution_y']; } else { if ($M['media_resolution_x'] == 0 && $M['remote_media'] != 1) { require_once $_CONF['path'] . '/lib/getid3/getid3.php'; // Needed for windows only define('GETID3_HELPERAPPSDIR', 'C:/helperapps/'); $getID3 = new getID3(); // Analyze file and store returned data in $MG_mediaFileInfo $MG_mediaFileInfo = $getID3->analyze($_MG_CONF['path_mediaobjects'] . 'orig/' . $M['media_filename'][0] . '/' . $M['media_filename'] . '.' . $M['media_mime_ext']); getid3_lib::CopyTagsToComments($MG_mediaFileInfo); if ($MG_mediaFileInfo['video']['resolution_x'] < 1 || $MG_mediaFileInfo['video']['resolution_y'] < 1) { if (isset($MG_mediaFileInfo['meta']['onMetaData']['width']) && isset($MG_mediaFileInfo['meta']['onMetaData']['height'])) { $resolution_x = $MG_mediaFileInfo['meta']['onMetaData']['width']; $resolution_y = $MG_mediaFileInfo['meta']['onMetaData']['height']; } else { $resolution_x = -1; $resolution_y = -1; } } else { $resolution_x = $MG_mediaFileInfo['video']['resolution_x']; $resolution_y = $MG_mediaFileInfo['video']['resolution_y']; } if ($resolution_x != 0) { $sql = "UPDATE " . $_TABLES['mg_media'] . " SET media_resolution_x=" . $resolution_x . ",media_resolution_y=" . $resolution_y . " WHERE media_id='" . DB_escapeString($M['media_id']) . "'"; DB_query($sql, 1); } } else { $resolution_x = $M['media_resolution_x']; $resolution_y = $M['media_resolution_y']; } } $resolution_x = $playback_options['width']; $resolution_y = $playback_options['height']; if ($resolution_x < 1 || $resolution_y < 1) { $resolution_x = 480; $resolution_y = 320; } else { $resolution_x = $resolution_x + 40; $resolution_y = $resolution_y + 40; } if ($M['mime_type'] == 'video/x-flv' && $_MG_CONF['use_flowplayer'] != 1) { $resolution_x = $resolution_x + 60; if ($resolution_x < 590) { $resolution_x = 590; } $resolution_y = $resolution_y + 80; if ($resolution_y < 500) { $resolution_y = 500; } } if ($M['media_type'] == 5) { $resolution_x = 460; $resolution_y = 380; } $url_display_item = "javascript:showVideo('" . $_MG_CONF['site_url'] . '/video.php?n=' . $M['media_id'] . "'," . $resolution_y . ',' . $resolution_x . ')'; } } else { $url_display_item = $_MG_CONF['site_url'] . '/download.php?mid=' . $M['media_id']; } // check to see if comments and rating are enabled, if not, put a link to edit... if ($MG_albums[0]->access == 3) { $T->set_var(array('edit_link' => '<br/><a href="' . $_MG_CONF['site_url'] . '/admin.php?mode=mediaedit&s=1&album_id=' . $M['album_id'] . '&mid=' . $M['media_id'] . '">' . $LANG_MG01['edit'] . '</a>')); } else { $T->set_var(array('edit_link' => '')); } } else { $url_display_item = $_MG_CONF['site_url'] . '/media.php?f=0' . '&sort=' . $sortOrder . '&s=' . $M['media_id'] . '&i=' . $id . '&p=' . $page; } if ($M['media_type'] == 4) { // other $url_display_item = $_MG_CONF['site_url'] . '/download.php?mid=' . $M['media_id']; } $media_size = @getimagesize($media_thumbnail_file); if ($media_size == false) { $default_thumbnail = 'missing.png'; $media_thumbnail = $_MG_CONF['mediaobjects_url'] . '/' . $default_thumbnail; $media_thumbnail_file = $_MG_CONF['path_mediaobjects'] . $default_thumbnail; $media_size = @getimagesize($media_thumbnail_file); } if ($_MG_CONF['use_upload_time'] == 1) { $media_time = MG_getUserDateTimeFormat($M['media_upload_time']); } else { $media_time = MG_getUserDateTimeFormat($M['media_time']); } $url_media_item = $url_display_item; // -- decide what thumbnail size to use, small, medium, large... if (isset($_MG_USERPREFS['tn_size']) && $_MG_USERPREFS['tn_size'] != -1) { $tn_size = $_MG_USERPREFS['tn_size']; } else { $tn_size = $_MG_CONF['gallery_tn_size']; } switch ($tn_size) { case '0': //small $tn_height = 100; break; case '1': //medium $tn_height = 150; break; case '2': $tn_height = 200; break; case '3': $tn_height = 200; break; default: $tn_height = 150; break; } if ($media_size[0] > $media_size[1]) { $ratio = $media_size[0] / $tn_height; $newwidth = $tn_height; $newheight = round($media_size[1] / $ratio); } else { $ratio = $media_size[1] / $tn_height; $newheight = $tn_height; $newwidth = round($media_size[0] / $ratio); } if ($media_size[0] > $media_size[1]) { $ratio = $media_size[0] / 50; $smallwidth = 50; $smallheight = round($media_size[1] / $ratio); } else { $ratio = $media_size[1] / 50; $smallheight = 50; $smallwidth = round($media_size[0] / $ratio); } if ($M['media_user_id'] != "" && $M['media_user_id'] > 1) { $username = DB_getItem($_TABLES['users'], 'username', "uid=" . $M['media_user_id']); } else { $username = '******'; } if ($M['mime_type'] == 'audio/mpeg') { $T->set_var(array('play_now' => '', 'download_now' => $_MG_CONF['site_url'] . '/download.php?mid=' . $M['media_id'], 'play_in_popup' => "javascript:showVideo('" . $_MG_CONF['site_url'] . '/video.php?n=' . $M['media_id'] . "'," . $resolution_y . ',' . $resolution_x . ')', 'mp3_file' => $_MG_CONF['mediaobjects_url'] . '/orig/' . $M['media_filename'][0] . '/' . $M['media_filename'] . '.' . $M['media_mime_ext'], 'site_url' => $_MG_CONF['site_url'], 'id' => $M['media_mime_ext'] . rand())); $T->parse('mp3_podcast', 'mp3_podcast'); } else { $T->set_var(array('mp3_podcast' => '')); } /* * build the small rating bar * */ if ($MG_albums[$M['album_id']]->enable_rating > 0) { $ip = $_SERVER['REMOTE_ADDR']; $uid = COM_isAnonUser() ? 1 : $_USER['uid']; $static = false; // check to see if we are the owner, if so, no rating for us... if (isset($_USER['uid']) && $_USER['uid'] == $M['media_user_id']) { $static = true; } else { if (in_array($M['media_id'], $ratedIds)) { $static = true; } else { $static = ''; } } if ($MG_albums[$M['album_id']]->enable_rating == 1 && COM_isAnonUser()) { $static = 'static'; } $rating_box = RATING_ratingBar('mediagallery', $M['media_id'], $M['media_votes'], $M['media_rating'], $static, 5, '', 'sm'); } else { $rating_box = ''; } $T->set_var('rating_box', $rating_box); if ($M['media_type'] == 0) { $direct_url = 'disp/' . $M['media_filename'][0] . '/' . $M['media_filename'] . '.' . $M['media_mime_ext']; if (!file_exists($_MG_CONF['path_mediaobjects'] . $direct_url)) { $direct_url = $_MG_CONF['mediaobjects_url'] . '/' . 'disp/' . $M['media_filename'][0] . '/' . $M['media_filename'] . '.jpg'; } else { $direct_url = $_MG_CONF['mediaobjects_url'] . '/' . $direct_url; } } else { $direct_url = $media_thumbnail; } if ($MG_albums[$M['album_id']]->access == 3) { $edit_item = '<a href="' . $_MG_CONF['site_url'] . '/admin.php?mode=mediaedit&s=1&album_id=' . $M['album_id'] . '&mid=' . $M['media_id'] . '">' . $LANG_MG01['edit'] . '</a>'; } else { $edit_item = ''; } $L = new Template(MG_getTemplatePath(0)); $L->set_file('media_link', 'medialink.thtml'); $L->set_var('href', $url_media_item); $L->set_var('hrefdirect', $direct_url); $L->set_var('caption', PLG_replaceTags($M['media_title'], 'mediagallery', 'media_title')); $L->set_var('id', 'id' . rand()); $L->parse('media_link_start', 'media_link'); $media_start_link = $L->finish($L->get_var('media_link_start')); $T->set_var(array('row_height' => $tn_height + 40, 'media_title' => isset($M['media_title']) && $M['media_title'] != '' && $M['media_title'] != ' ' ? PLG_replaceTags($M['media_title'], 'mediagallery', 'media_title') : '', 'media_description' => isset($M['media_desc']) && $M['media_desc'] != '' && $M['media_desc'] != ' ' ? PLG_replaceTags($M['media_desc'], 'mediagallery', 'media_title') : '', 'media_tag' => isset($M['media_title']) && $M['media_title'] != '' && $M['media_title'] != ' ' ? strip_tags($M['media_title']) : '', 'media_time' => $media_time[0], 'media_owner' => $username, 'site_url' => $_MG_CONF['site_url'], 'lang_published' => $LANG_MG03['published'], 'lang_on' => $LANG_MG03['on'], 'media_link_start' => '<a href="' . $url_media_item . '">', 'media_link_end' => '</a>', 'artist' => isset($M['artist']) && $M['artist'] != ' ' ? $M['artist'] : '', 'musicalbum' => isset($M['album']) && $M['album'] != ' ' ? $M['album'] : '', 'genre' => isset($M['genre']) && $M['genre'] != ' ' ? $M['genre'] : '', 'search_album' => $LANG_MG01['album'] . ': <a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $M['album_id'] . '">' . $MG_albums[$M['album_id']]->title . '</a>')); // frame template variables $F->set_var(array('media_link_start' => $media_start_link, 'media_link_end' => '</a>', 'url_media_item' => $url_media_item, 'url_display_item' => $url_display_item, 'media_thumbnail' => $media_thumbnail, 'media_size' => 'width="' . $newwidth . '" height="' . $newheight . '"', 'media_height' => $newheight, 'media_width' => $newwidth, 'border_width' => $newwidth + 15, 'border_height' => $newheight + 15, 'row_height' => $tn_height + 40, 'frWidth' => $newwidth - $frWidth, 'frHeight' => $newheight - $frHeight, 'media_tag' => strip_tags($M['media_desc']), 'search_album' => $LANG_MG01['album'] . ': <a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $M['album_id'] . '">' . $MG_albums[$M['album_id']]->title . '</a>')); $F->parse('media', 'media_frame'); $media_item_thumbnail = $F->finish($F->get_var('media')); $T->set_var('media_item_thumbnail', $media_item_thumbnail); if (!empty($M['media_keywords'])) { $kwText = ''; $keyWords = array(); $keyWords = explode(' ', $M['media_keywords']); $numKeyWords = count($keyWords); for ($i = 0; $i < $numKeyWords; $i++) { $keyWords[$i] = str_replace('"', ' ', $keyWords[$i]); $searchKeyword = $keyWords[$i]; $keyWords[$i] = str_replace('_', ' ', $keyWords[$i]); $kwText .= $keyWords[$i] . ' '; } $T->set_var(array('media_keywords' => $kwText, 'lang_keywords' => $LANG_MG01['keywords'])); $T->parse('media_cell_keywords', 'media_cell_keywords'); } else { $T->set_var('lang_keywords', ''); } if ($_MG_CONF['search_enable_rating']) { if ($M['media_type'] == 4 || $M['media_type'] == 1 && $playback_type != 2 || $M['media_type'] == 2 && $playback_type != 2 || $M['media_type'] == 5 && $playback_type != 2) { $rateLink = '<a href="' . $_MG_CONF['site_url'] . '/media.php?f=0' . '&sort=' . $sortOrder . '&s=' . $M['media_id'] . '">' . $LANG_MG03['rating'] . '</a>'; } else { $rateLink = $LANG_MG03['rating']; } $rating = $rateLink . ': <strong> ' . $M['media_rating'] / 2 . '</strong>/5 (' . $M['media_votes'] . ' ' . $LANG_MG03['votes'] . ')'; $T->set_var(array('media_rating' => $rating)); $T->parse('media_rate_results', 'media_rate_results'); } if ($_MG_CONF['search_enable_views']) { $T->set_var(array('media_views_count' => $M['media_views'], 'lang_views' => $LANG_MG03['views'])); $T->parse('media_views', 'media_views'); } $T->parse('media_cell', 'media_cell_image'); $retval = $T->finish($T->get_var('media_cell')); return $retval; }
/** * Determines if user is allowed to use the search form * * Geeklog has a number of settings that may prevent * the access anonymous users have to the search engine. * This performs those checks * * @author Dirk Haun, dirk AT haun-online DOT de * @return boolean True if form usage is allowed, otherwise false * */ private function _isFormAllowed() { global $_CONF; if (COM_isAnonUser() and ($_CONF['loginrequired'] == 1 or $_CONF['searchloginrequired'] >= 1)) { return false; } return true; }
/** * Display form to email a story to someone. * * @param string $sid ID of article to email * @return string HTML for email story form * */ function mailstoryform($sid, $to = '', $toemail = '', $from = '', $fromemail = '', $shortmsg = '', $msg = 0) { global $_CONF, $_TABLES, $_USER, $LANG08, $LANG_LOGIN; require_once $_CONF['path_system'] . 'lib-story.php'; $retval = ''; if (COM_isAnonUser() && ($_CONF['loginrequired'] == 1 || $_CONF['emailstoryloginrequired'] == 1)) { $retval = COM_startBlock($LANG_LOGIN[1], '', COM_getBlockTemplate('_msg_block', 'header')); $login = new Template($_CONF['path_layout'] . 'submit'); $login->set_file(array('login' => 'submitloginrequired.thtml')); $login->set_var('xhtml', XHTML); $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('login_message', $LANG_LOGIN[2]); $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; } $story = new Story(); $result = $story->loadFromDatabase($sid, 'view'); if ($result != STORY_LOADED_OK) { return COM_refresh($_CONF['site_url'] . '/index.php'); } if ($msg > 0) { $retval .= COM_showMessage($msg); } if (empty($from) && empty($fromemail)) { if (!COM_isAnonUser()) { $from = COM_getDisplayName($_USER['uid'], $_USER['username'], $_USER['fullname']); $fromemail = DB_getItem($_TABLES['users'], 'email', "uid = {$_USER['uid']}"); } } $mail_template = new Template($_CONF['path_layout'] . 'profiles'); $mail_template->set_file('form', 'contactauthorform.thtml'); $mail_template->set_var('xhtml', XHTML); $mail_template->set_var('site_url', $_CONF['site_url']); $mail_template->set_var('site_admin_url', $_CONF['site_admin_url']); $mail_template->set_var('layout_url', $_CONF['layout_url']); $mail_template->set_var('start_block_mailstory2friend', COM_startBlock($LANG08[17])); $mail_template->set_var('lang_title', $LANG08[31]); $mail_template->set_var('story_title', $story->displayElements('title')); $url = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $sid); $mail_template->set_var('story_url', $url); $link = COM_createLink($story->displayElements('title'), $url); $mail_template->set_var('story_link', $link); $mail_template->set_var('lang_fromname', $LANG08[20]); $mail_template->set_var('name', $from); $mail_template->set_var('lang_fromemailaddress', $LANG08[21]); $mail_template->set_var('email', $fromemail); $mail_template->set_var('lang_toname', $LANG08[18]); $mail_template->set_var('toname', $to); $mail_template->set_var('lang_toemailaddress', $LANG08[19]); $mail_template->set_var('toemail', $toemail); $mail_template->set_var('lang_cc', $LANG08[36]); $mail_template->set_var('lang_cc_description', $LANG08[37]); $mail_template->set_var('lang_shortmessage', $LANG08[27]); $mail_template->set_var('shortmsg', htmlspecialchars($shortmsg)); $mail_template->set_var('lang_warning', $LANG08[22]); $mail_template->set_var('lang_sendmessage', $LANG08[16]); $mail_template->set_var('story_id', $sid); $mail_template->set_var('end_block', COM_endBlock()); PLG_templateSetVars('emailstory', $mail_template); $mail_template->parse('output', 'form'); $retval .= $mail_template->finish($mail_template->get_var('output')); return $retval; }
function MB_displayMenuList() { global $_CONF, $_USER, $_TABLES, $LANG_MB01, $LANG_MB_ADMIN, $LANG_ADMIN, $LANG_MB_MENU_TYPES; $retval = ''; $menuArray = array(); $mbadmin = SEC_hasRights('menu.admin'); $root = SEC_inGroup('Root'); if (COM_isAnonUser()) { $uid = 1; } else { $uid = $_USER['uid']; } $result = DB_query("SELECT * FROM {$_TABLES['menu']}", 1); while ($menu = DB_fetchArray($result)) { $menuID = $menu['id']; $menuArray[$menu['id']]['menu_name'] = $menu['menu_name']; $menuArray[$menu['id']]['menu_id'] = $menu['id']; $menuArray[$menu['id']]['active'] = $menu['menu_active']; $menuArray[$menu['id']]['menu_type'] = $menu['menu_type']; $menuArray[$menu['id']]['group_id'] = $menu['group_id']; if ($mbadmin || $root) { $menuArray[$menu['id']]['menu_perm'] = 3; } else { if ($menuArray['group_id'] == 998) { if (COM_isAnonUser()) { $menuArray[$menu['id']]['menu_perm'] = 3; } else { $menuArray[$menu['id']]['menu_perm'] = 0; } } else { if (in_array($menu['group_id'], $_GROUPS)) { $menuArray[$menu['id']]['menu_perm'] = 3; } } } } $menu_arr = array(array('url' => $_CONF['site_admin_url'] . '/menu.php?mode=newmenu', 'text' => $LANG_MB01['add_newmenu']), array('url' => $_CONF['site_admin_url'], 'text' => $LANG_ADMIN['admin_home'])); $retval .= COM_startBlock($LANG_MB01['menu_builder'], '', COM_getBlockTemplate('_admin_block', 'header')); $retval .= ADMIN_createMenu($menu_arr, $LANG_MB_ADMIN[1], $_CONF['layout_url'] . '/images/icons/menubuilder.png'); $data_arr = array(); $text_arr = array(); $options = array(); $header_arr = array(array('text' => $LANG_MB01['label'], 'field' => 'menu_name'), array('text' => $LANG_MB01['clone'], 'field' => 'copy', 'align' => 'center'), array('text' => $LANG_MB01['active'], 'field' => 'active', 'align' => 'center'), array('text' => $LANG_MB01['elements'], 'field' => 'elements', 'align' => 'center'), array('text' => $LANG_MB01['options'], 'field' => 'options', 'align' => 'center'), array('text' => $LANG_MB01['delete'], 'field' => 'delete', 'align' => 'center')); $text_arr = array('has_menu' => false, 'title' => '', 'help_url' => '', 'no_data' => $LANG_MB01['no_elements'], 'form_url' => "{$_CONF['site_admin_url']}/menu.php"); $form_arr['bottom'] = ' <input type="hidden" name="mode" value="menuactivate" /> <script type="text/javascript"> document.getElementById(\'menubuilder\').style.display=\'\' </script> '; if (is_array($menuArray)) { foreach ($menuArray as $menu) { $menu_entry['menu_id'] = $menu['menu_id']; $menu_entry['menu_name'] = $menu['menu_name']; $menu_entry['copy'] = $menu['menu_id']; $menu_entry['active'] = $menu['active']; $menu_entry['elements'] = $menu['menu_id']; $menu_entry['options'] = $menu['menu_id']; $menu_entry['delete'] = $menu['menu_id']; $menu_entry['menu_type'] = $menu['menu_type']; $menu_entry['info'] = $menu['menu_name'] . '::' . '<b>' . $LANG_MB01['type'] . ':</b><br />' . $LANG_MB_MENU_TYPES[$menu['menu_type']] . '<br/>'; $data_arr[] = $menu_entry; } } $retval .= ADMIN_simpleList("_mb_getListField_menulist", $header_arr, $text_arr, $data_arr, $options, $form_arr); $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')); $outputHandle = outputHandler::getInstance(); $outputHandle->addLinkScript($_CONF['site_url'] . '/javascript/admin.js', HEADER_PRIO_NORMAL, 'text/javascript'); return $retval; }
// | This program is distributed in the hope that it will be useful, | // | but WITHOUT ANY WARRANTY; without even the implied warranty of | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | // | GNU General Public License for more details. | // | | // | You should have received a copy of the GNU General Public License | // | along with this program; if not, write to the Free Software Foundation, | // | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | // | | // +--------------------------------------------------------------------------+ require_once '../lib-common.php'; if (!in_array('mediagallery', $_PLUGINS)) { echo COM_refresh($_CONF['site_url'] . '/index.php'); exit; } if (COM_isAnonUser() && $_MG_CONF['loginrequired'] == 1) { $display = SEC_loginRequiredForm(); $display = MG_createHTMLDocument($display); COM_output($display); exit; } require_once $_CONF['path'] . 'plugins/mediagallery/include/common.php'; // Implements a poor mans hotlink protection, if the request // did not originate at our site, don't allow it. $referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; $allowed = 0; if ($referrer == '') { $allowed = 1; } else { if (strpos($referrer, $_CONF['site_url']) !== false) { $allowed = 1;
function _mg_profilesave($uid = 0) { global $_CONF, $_MG_CONF, $_TABLES, $_USER; if (COM_isAnonUser()) { return; } if ($_MG_CONF['up_display_rows_enabled'] == 0 && $_MG_CONF['up_display_columns_enabled'] == 0 && $_MG_CONF['up_mp3_player_enabled'] == 0 && $_MG_CONF['up_av_playback_enabled'] == 0 && $_MG_CONF['up_thumbnail_size_enabled'] == 0) { return; } $display_rows = (int) COM_applyFilter($_POST['display_rows'], true); $display_columns = (int) COM_applyFilter($_POST['display_columns'], true); $mp3_player = isset($_POST['mp3_player']) ? (int) COM_applyFilter($_POST['mp3_player'], true) : 0; $playback_mode = (int) COM_applyFilter($_POST['playback_mode'], true); $tn_size = (int) COM_applyFilter($_POST['tn_size'], true); $uid = $uid == 0 ? (int) $_USER['uid'] : (int) $uid; if ($display_columns < 0 || $display_columns > 5) { $display_columns = 3; } if ($display_rows < 0 || $display_rows > 99) { $display_rows = 4; } if ($_MG_CONF['up_display_rows_enabled'] == 0) { $display_rows = 0; } if ($_MG_CONF['up_display_columns_enabled'] == 0) { $display_columns = 0; } if ($_MG_CONF['up_mp3_player_enabled'] == 0) { $mp3_player = -1; } if ($_MG_CONF['up_av_playback_enabled'] == 0) { $playback_mode = -1; } if ($_MG_CONF['up_thumbnail_size_enabled'] == 0) { $tn_size = -1; } $active = 1; // Let's see if user exists in table already $result = DB_query("SELECT * FROM " . $_TABLES['mg_userprefs'] . " WHERE uid=" . (int) $uid); if (DB_numRows($result) > 0) { $row = DB_fetchArray($result); $quota = $row['quota']; $member_gallery = $row['member_gallery']; } else { $quota = $_MG_CONF['member_quota']; $member_gallery = 0; } DB_save($_TABLES['mg_userprefs'], 'uid,active,display_rows,display_columns,mp3_player,playback_mode,tn_size,member_gallery,quota', "{$uid},{$active},{$display_rows},{$display_columns},{$mp3_player},{$playback_mode},{$tn_size},{$member_gallery},{$quota}"); }
/** * Save an event to user's personal calendar * * User has seen the confirmation screen and they still wants to * add this event to their calendar. Actually save it now. * * @param string $eid ID of event to save * @return string HTML refresh * */ function saveuserevent($eid) { global $_CONF, $_TABLES, $_USER; if (!COM_isAnonUser()) { // Try to delete the event first in case it has already been added DB_query("DELETE FROM {$_TABLES['personal_eventsjp']} WHERE uid={$_USER['uid']} AND eid='{$eid}'"); $result = DB_query("SELECT eid FROM {$_TABLES['eventsjp']} WHERE (eid = '{$eid}')" . COM_getPermSql('AND')); if (DB_numRows($result) == 1) { $savesql = "INSERT INTO {$_TABLES['personal_eventsjp']} " . "(eid,uid,title,event_type,datestart,dateend,timestart,timeend,allday,location,address1,address2,city,state," . "zipcode,url,description,group_id,owner_id,perm_owner,perm_group,perm_members,perm_anon) SELECT eid," . $_USER['uid'] . ",title,event_type,datestart,dateend,timestart,timeend,allday,location,address1,address2," . "city,state,zipcode,url,description,group_id,owner_id,perm_owner,perm_group,perm_members,perm_anon FROM " . "{$_TABLES['eventsjp']} WHERE eid = '{$eid}'"; DB_query($savesql); return COM_refresh($_CONF['site_url'] . '/calendarjp/index.php?mode=personal&msg=24'); } } return COM_refresh($_CONF['site_url'] . '/index.php'); }
} $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); $T->set_var('IColumn', ''); break 2;
/** * Prepare a banner item for rendering * * @param array $A banner details * @param ref $template reference of the banner template * */ function prepare_banner_item($A, &$template) { global $_CONF, $_USER, $LANG_ADMIN, $LANG_BANNER, $_IMAGE_TYPE, $LANG_DIRECTION; $url = COM_buildUrl($_CONF['site_url'] . '/banner/portal.php?what=banner&item=' . $A['bid']); $template->set_var('banner_url', $url); $template->set_var('banner_actual_url', $A['url']); $template->set_var('banner_actual_url_encoded', urlencode($A['url'])); $template->set_var('banner_name', stripslashes($A['title'])); $template->set_var('banner_name_encoded', urlencode($A['title'])); $template->set_var('banner_hits', COM_numberFormat($A['hits'])); $content = stripslashes($A['title']); $template->set_var('banner_html', $content); if (!COM_isAnonUser() && !SEC_hasRights('banner.edit')) { $reporturl = $_CONF['site_url'] . '/banner/index.php?mode=report&bid=' . $A['bid']; $template->set_var('banner_broken', COM_createLink($LANG_BANNER[117], $reporturl, array('class' => 'pluginSmallText', 'rel' => 'nofollow'))); } else { $template->set_var('banner_broken', ''); } $bannerimg = nl2br(stripslashes($A['description'])); $flg_link = empty($A['url']) ? false : true; $banner = banner_buildBanner($A['bid'], $content, $bannerimg, $flg_link); $template->set_var('banner_description', $banner); if (SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']) == 3 && SEC_hasRights('banner.edit')) { $editurl = $_CONF['site_admin_url'] . '/plugins/banner/index.php?mode=edit&bid=' . $A['bid']; $template->set_var('banner_edit', COM_createLink($LANG_ADMIN['edit'], $editurl)); $edit_icon = "<img src=\"{$_CONF['layout_url']}/images/edit.{$_IMAGE_TYPE}\" " . "alt=\"{$LANG_ADMIN['edit']}\" title=\"{$LANG_ADMIN['edit']}\"" . XHTML . ">"; $attr = array('class' => 'editlink'); $template->set_var('edit_icon', COM_createLink($edit_icon, $editurl, $attr)); } else { $template->set_var('banner_edit', ''); $template->set_var('edit_icon', ''); } }
function MG_index() { global $_USER, $_MG_CONF, $_CONF, $_TABLES, $MG_albums, $LANG_MG00, $LANG_MG01, $LANG_MG02, $LANG_MG03, $themeStyle; $display = ''; $media_size = false; $page = 0; if (isset($_GET['page'])) { $page = COM_applyFilter($_GET['page'], true); } if ($page != 0) { $page = $page - 1; } $themeStyle = MG_getThemeCSS(0); if (!isset($_MG_CONF['album_display_columns']) || $_MG_CONF['album_display_columns'] < 1) { $_MG_CONF['album_display_columns'] = 1; } switch ($_MG_CONF['album_display_columns']) { case 1: $albumListTemplate = 'gallery_page_body_1.thtml'; $albumColumnWidth = "100%"; break; case 2: $albumListTemplate = 'gallery_page_body_2.thtml'; $albumColumnWidth = "50%"; break; default: $albumListTemplate = 'gallery_page_body_3.thtml'; $albumColumnWidth = @intval(100 / $_MG_CONF['album_display_columns']) . '%'; if ($albumColumnWidth == 0) { $albumColumnWidth = "25%"; } break; } $T = new Template(MG_getTemplatePath(0)); $T->set_file(array('page' => 'gallery_page.thtml', 'body' => $albumListTemplate, 'noitems' => 'gallery_page_noitems.thtml')); $T->set_var(array('lang_menulabel' => $_MG_CONF['menulabel'], 'lang_search' => $LANG_MG01['search'], 'site_url' => $_MG_CONF['site_url'])); if ($_MG_CONF['rss_full_enabled']) { $feedUrl = MG_getFeedUrl($_MG_CONF['rss_feed_name'] . '.rss'); $rsslink = '<a href="' . $feedUrl . '"' . ' type="application/rss+xml">'; $rsslink .= '<img src="' . MG_getImageFile('feed.png') . '" alt="" style="border:none;"/></a>'; $T->set_var('rsslink', $rsslink); $T->set_var('rsslink_url', $feedUrl); } else { $T->set_var('rsslink', ''); } $nFrame = new mgFrame(); $nFrame->constructor($_MG_CONF['indexskin']); $MG_albums[0]->albumFrameTemplate = $nFrame->getTemplate(); $MG_albums[0]->afrWidth = $nFrame->frame['wHL'] + $nFrame->frame['wHR']; $MG_albums[0]->afrHeight = $nFrame->frame['hVT'] + $nFrame->frame['hVB']; // Let's build our admin menu options $showAdminBox = 0; $admin_box_item = ''; $admin_box = '<form name="adminbox" id="adminbox" action="' . $_MG_CONF['site_url'] . '/admin.php" method="get" style="margin:0;padding:0;">' . LB; $admin_box .= '<div>'; $admin_box .= '<select onchange="javascript:forms[\'adminbox\'].submit();" name="mode">' . LB; $admin_box_item .= '<option label="' . $LANG_MG01['options'] . '" value="">' . $LANG_MG01['options'] . '</option>' . LB; if (($MG_albums[0]->member_uploads || $MG_albums[0]->access == 3) && !COM_isAnonUser()) { $admin_box_item .= '<option value="upload">' . $LANG_MG01['add_media'] . '</option>' . LB; $showAdminBox = 1; } if ($MG_albums[0]->owner_id) { $admin_box_item .= '<option value="albumsort">' . $LANG_MG01['sort_albums'] . '</option>' . LB; $admin_box_item .= '<option value="globalattr">' . $LANG_MG01['globalattr'] . '</option>' . LB; $admin_box_item .= '<option value="globalperm">' . $LANG_MG01['globalperm'] . '</option>' . LB; $queue_count = DB_count($_TABLES['mg_media_album_queue']); $admin_box_item .= '<option value="moderate">' . $LANG_MG01['media_queue'] . ' (' . $queue_count . ')</option>' . LB; $admin_box_item .= '<option value="wmmanage">' . $LANG_MG01['wm_management'] . '</option>' . LB; $admin_box_item .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>' . LB; $showAdminBox = 1; } elseif ($MG_albums[0]->access == 3) { $admin_box_item .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>' . LB; $showAdminBox = 1; } elseif ($_MG_CONF['member_albums'] == 1 && !COM_isAnonUser() && $_MG_CONF['member_album_root'] == 0 && $_MG_CONF['member_create_new']) { $admin_box_item .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>' . LB; $showAdminBox = 1; } $admin_box .= $admin_box_item; $admin_box .= '</select>' . LB; $admin_box .= '<input type="hidden" name="album_id" value="0"/>' . LB; $admin_box .= ' <input type="submit" value="' . $LANG_MG03['go'] . '"/>' . LB; $admin_box .= '</div>'; $admin_box .= '</form>'; // build ul $admin_menu = ''; $showAdminMenu = 0; $admin_url = $_MG_CONF['site_url'] . '/admin.php?album_id=0'; if (($MG_albums[0]->member_uploads || $MG_albums[0]->access == 3) && !COM_isAnonUser()) { $admin_menu .= '<li><a href="' . $admin_url . '&mode=upload">' . $LANG_MG01['add_media'] . '</a></li>'; $showAdminMenu = 1; } if ($MG_albums[0]->owner_id) { $admin_menu .= '<li><a href="' . $admin_url . '&mode=albumsort">' . $LANG_MG01['sort_albums'] . '</a></li>'; $admin_menu .= '<li><a href="' . $admin_url . '&mode=globalattr">' . $LANG_MG01['globalattr'] . '</a></li>' . LB; $admin_menu .= '<li><a href="' . $admin_url . '&mode=globalperm">' . $LANG_MG01['globalperm'] . '</a></li>' . LB; $queue_count = DB_count($_TABLES['mg_media_album_queue']); $admin_menu .= '<li><a href="' . $admin_url . '&mode=moderate">' . $LANG_MG01['media_queue'] . ' (' . $queue_count . ')</a></li>' . LB; $admin_menu .= '<li><a href="' . $admin_url . '&mode=wmmanage">' . $LANG_MG01['wm_management'] . '</a></li>' . LB; $admin_menu .= '<li><a href="' . $admin_url . '&mode=create">' . $LANG_MG01['create_album'] . '</a></li>' . LB; $showAdminMenu = 1; } elseif ($MG_albums[0]->access == 3) { $admin_Menu .= '<li><a href="' . $abmin_url . '&mode=create">' . $LANG_MG01['create_album'] . '</a></li>' . LB; $showAdminMenu = 1; } elseif ($_MG_CONF['member_albums'] == 1 && !COM_isAnonUser() && $_MG_CONF['member_album_root'] == 0 && $_MG_CONF['member_create_new']) { $admin_menu .= '<li><a href="' . $admin_url . '&mode=create">' . $LANG_MG01['create_album'] . '</a></li>' . LB; $showAdminMenu = 1; } // end of ul if ($showAdminBox == 0) { $admin_box = ''; $admin_box_item = ''; } if ($showAdminMenu == 1) { $T->set_var('admin_menu', $admin_menu); } $T->set_var('select_adminbox', $admin_box); $T->set_var('select_box_items', $admin_box_item); $album_count = 0; $width = intval(100 / $_MG_CONF['album_display_columns']); $rowcounter = 0; $albumCount = 0; $indexCounter = 0; if (COM_isAnonUser()) { $lastlogin = time(); } else { if (!COM_isAnonUser()) { $lastlogin = $_USER['lastlogin']; } else { $lastlogin = time(); } } $children = $MG_albums[0]->getChildren(); $nrows = count($children); $checkCounter = 0; $aCount = 0; $achild = array(); for ($i = 0; $i < $nrows; $i++) { $access = $MG_albums[$children[$i]]->access; if ($access == 0 || $MG_albums[$children[$i]]->hidden == 1 && $access != 3) { // no op } else { $achild[] = $MG_albums[$children[$i]]->id; $aCount++; } } if ($_MG_CONF['album_display_rows'] < 1) { $_MG_CONF['album_display_rows'] = 9; } $items_per_page = $_MG_CONF['album_display_columns'] * $_MG_CONF['album_display_rows']; $begin = $items_per_page * $page; $end = $items_per_page; $nrows = count($achild); $indexCounter = $begin; $noParse = 0; $needFinalParse = 0; if ($nrows > 0) { $k = 0; $T->set_block('body', 'AlbumColumn', 'AColumn'); $T->set_block('body', 'AlbumRow', 'ARow'); for ($i = $begin; $i < $begin + $items_per_page; $i += $_MG_CONF['album_display_columns']) { for ($j = $i; $j < $i + $_MG_CONF['album_display_columns']; $j++) { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg'; if ($j >= $nrows) { $k = $i + $_MG_CONF['album_display_columns'] - $j; $m = $k % $_MG_CONF['album_display_columns']; for ($z = $m; $z > 0; $z--) { $needFinalParse = 1; } if ($needFinalParse == 1) { $T->parse('ARow', 'AlbumRow', true); $T->set_var('AColumn', ''); } $noParse = 1; break; } $access = $MG_albums[$achild[$indexCounter]]->access; if ($access == 0 || $MG_albums[$achild[$indexCounter]]->hidden == 1 && $access != 3) { $j--; $indexCounter++; continue; } $albumCount++; if ($MG_albums[$achild[$indexCounter]]->media_count > 0) { if ($MG_albums[$achild[$indexCounter]]->cover_filename != '' && $MG_albums[$achild[$indexCounter]]->cover_filename != '0') { $album_last_update = MG_getUserDateTimeFormat($MG_albums[$achild[$indexCounter]]->last_update); if (substr($MG_albums[$achild[$indexCounter]]->cover_filename, 0, 3) == 'tn_') { $offset = 3; } else { $offset = 0; } foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $MG_albums[$achild[$indexCounter]]->cover_filename[$offset] . '/' . $MG_albums[$achild[$indexCounter]]->cover_filename . $ext)) { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/tn/' . $MG_albums[$achild[$indexCounter]]->cover_filename[$offset] . '/' . $MG_albums[$achild[$indexCounter]]->cover_filename . $ext; $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $MG_albums[$achild[$indexCounter]]->cover_filename[$offset] . '/' . $MG_albums[$achild[$indexCounter]]->cover_filename . $ext); break; } } $album_media_count = $MG_albums[$achild[$indexCounter]]->media_count; if (!COM_isAnonUser()) { if ($MG_albums[$achild[$indexCounter]]->last_update > $lastlogin) { $album_last_update[0] = '<font color="red">' . $album_last_update[0] . '</font>'; } } $T->set_var(array('updated_prompt' => $_MG_CONF['dfid'] == '99' ? '' : $LANG_MG03['updated_prompt'])); } else { $album_media_count = $MG_albums[$achild[$indexCounter]]->media_count; $album_last_update = MG_getUserDateTimeFormat($MG_albums[$achild[$indexCounter]]->last_update); $filename = $MG_albums[$achild[$indexCounter]]->findCover(); if ($filename == '') { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg'; $media_size = array(200, 200); } else { if (substr($filename, 0, 3) == 'tn_') { $offset = 3; } else { $offset = 0; } foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $filename[$offset] . '/' . $filename . $ext)) { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/tn/' . $filename[$offset] . '/' . $filename . $ext; $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $filename[$offset] . '/' . $filename . $ext); break; } } } $T->set_var(array('updated_prompt' => $_MG_CONF['dfid'] == '99' ? '' : $LANG_MG03['updated_prompt'])); } } else { // nothing in the album yet... // here we need to search the sub-albums if any and see if we can find a picture.... $album_media_count = 0; $album_last_update[0] = ""; $filename = $MG_albums[$achild[$indexCounter]]->findCover(); if ($filename == '') { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg'; $media_size = array(200, 200); } else { foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $filename[0] . '/' . $filename . $ext)) { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/tn/' . $filename[0] . '/' . $filename . $ext; $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $filename[0] . '/' . $filename . $ext); break; } } } $T->set_var('updated_prompt', ''); } $T->clear_var(array('lang_views', 'views')); if ($MG_albums[$achild[$indexCounter]]->enable_album_views) { $T->set_var(array('lang_views' => $LANG_MG03['views'], 'views' => $MG_albums[$achild[$indexCounter]]->views)); } if ($MG_albums[$achild[$indexCounter]]->tn_attached == 1) { $media_size = false; foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'covers/cover_' . $MG_albums[$achild[$indexCounter]]->id . $ext)) { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/covers/cover_' . $MG_albums[$achild[$indexCounter]]->id . $ext; $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'covers/cover_' . $MG_albums[$achild[$indexCounter]]->id . $ext); break; } } } // a little fail safe here to make sure we don't show empty boxes... if ($media_size === false || $media_size[0] == 0 || $media_size[1] == 0) { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg'; $media_size = array(200, 200); } // set the image size here... switch ($_MG_CONF['gallery_tn_size']) { case '0': //small $tn_height = 100; $tn_width = 100; break; case '1': //medium $tn_height = 150; $tn_width = 150; break; case '2': $tn_height = 200; $tn_width = 200; break; case '3': $tn_height = $_MG_CONF['gallery_tn_height']; $tn_width = $_MG_CONF['gallery_tn_width']; break; default: $tn_height = 200; $tn_width = 200; break; } if ($media_size[0] > $media_size[1]) { $ratio = $media_size[0] / $tn_height; $newwidth = $tn_height; $newheight = @round($media_size[1] / $ratio); } else { $ratio = $media_size[1] / $tn_height; $newheight = $tn_height; $newwidth = @round($media_size[0] / $ratio); } // pull the sub-album info here $subAlbumDisplay = ''; if (isset($_MG_CONF['subalbum_select']) && $_MG_CONF['subalbum_select'] == 1) { $subAlbumDisplay = '<form name="subalbums' . $MG_albums[$achild[$indexCounter]]->id . '" action="' . $_MG_CONF['site_url'] . '/album.php' . '" method="get" style="margin:0;padding:0">'; $subAlbumDisplay .= '<select name="aid" onchange="forms[\'subalbums' . $MG_albums[$achild[$indexCounter]]->id . '\'].submit()">'; $subAlbumDisplay .= '<optgroup label="' . $LANG_MG01['select_subalbum'] . '">' . LB; } $saRows = 0; $T->clear_var(array('lang_subalbums', 'subalbumcount', 'subalbumlist')); if (!empty($MG_albums[$achild[$indexCounter]]->children)) { $SAchildren = $MG_albums[$achild[$indexCounter]]->getChildren(); foreach ($SAchildren as $SAchild) { if ($MG_albums[$SAchild]->access > 0) { if ($MG_albums[$SAchild]->hidden) { if ($MG_albums[$SAchild]->access == 3) { $mediaCount = $MG_albums[$SAchild]->getMediaCount(); if ($_MG_CONF['subalbum_select'] == 1) { if (strlen($MG_albums[$SAchild]->title) > 50) { $aTitle = substr($MG_albums[$SAchild]->title, 0, 50) . '...'; } else { $aTitle = $MG_albums[$SAchild]->title; } $subAlbumDisplay .= '<option value="' . $MG_albums[$SAchild]->id . '">' . $aTitle . ' (' . $mediaCount . ')</option>'; } else { $subAlbumDisplay .= '<li><a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$SAchild]->id . '&page=1' . '">' . $MG_albums[$SAchild]->title . ' (' . $mediaCount . ')</a></li>'; } $saRows++; } } else { $mediaCount = $MG_albums[$SAchild]->getMediaCount(); if ($_MG_CONF['subalbum_select'] == 1) { if (strlen($MG_albums[$SAchild]->title) > 50) { $aTitle = substr($MG_albums[$SAchild]->title, 0, 50) . '...'; } else { $aTitle = $MG_albums[$SAchild]->title; } $subAlbumDisplay .= '<option value="' . $MG_albums[$SAchild]->id . '">' . $aTitle . ' (' . $mediaCount . ')</option>'; } else { $subAlbumDisplay .= '<li><a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$SAchild]->id . '&page=1' . '">' . $MG_albums[$SAchild]->title . ' (' . $mediaCount . ')</a></li>'; } $saRows++; } } } if ($_MG_CONF['subalbum_select'] == 1) { $subAlbumDisplay .= '</optgroup></select>'; $subAlbumDisplay .= ' <input type="submit" value="' . $LANG_MG03['go'] . '" />'; $subAlbumDisplay .= '<input type="hidden" name="page" value="1"/>'; $subAlbumDisplay .= '</form>'; } if ($_MG_CONF['album_display_columns'] > 1 && $_MG_CONF['subalbum_select'] != 1) { $T->set_var(array('subalbumlist' => '<span style="font-weight:bold;">' . $LANG_MG01['subalbums'] . '</span> (' . $saRows . ')')); } else { $T->set_var(array('lang_subalbums' => $LANG_MG01['subalbums'], 'subalbumcount' => '(' . $saRows . ')', 'subalbumlist' => $subAlbumDisplay)); } } if ($saRows == 0) { $T->clear_var(array('lang_subalbums', 'subalbumcount', 'subalbumlist')); } $T->clear_var(array('saulstart', 'saulend')); if ($saRows > 0 && $_MG_CONF['subalbum_select'] != 1) { $T->set_var(array('saulstart' => '<ul>', 'saulend' => '</ul>')); } // now pull the total image count for all sub albums... $total_images_subalbums = $MG_albums[$achild[$indexCounter]]->getMediaCount(); $owner_id = $MG_albums[$achild[$indexCounter]]->owner_id; if ($owner_id == '' || !isset($MG_albums[$achild[$indexCounter]]->owner_id)) { $owner_id = 0; } $ownername = DB_getItem($_TABLES['users'], 'username', "uid=" . intval($owner_id)); $F = new Template($_MG_CONF['template_path']); $F->set_var('media_frame', $MG_albums[0]->albumFrameTemplate); $F->set_var(array('border_width' => $newwidth + 20, 'border_height' => $newheight + 20, 'media_link_start' => '<a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$achild[$indexCounter]]->id . '&page=1' . '">', 'media_link_end' => '</a>', 'url_media_item' => $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$achild[$indexCounter]]->id . '&page=1', 'media_thumbnail' => $album_last_image, 'media_size' => 'width="' . $newwidth . '" height="' . $newheight . '"', 'media_height' => $newheight, 'media_width' => $newwidth, 'media_tag' => strip_tags($MG_albums[$achild[$indexCounter]]->title), 'frWidth' => $newwidth - $MG_albums[0]->afrWidth, 'frHeight' => $newheight - $MG_albums[0]->afrHeight)); $F->parse('media', 'media_frame'); $media_item_thumbnail = $F->finish($F->get_var('media')); $T->set_var(array('media_item_thumbnail' => $media_item_thumbnail, 'class' => $rowcounter % 2, 'table_column_width' => 'width="' . $width . '%"', 'album_id' => $MG_albums[$achild[$indexCounter]]->id, 'album_title' => PLG_replaceTags($MG_albums[$achild[$indexCounter]]->title, 'mediagallery', 'album_title'), 'album_desc' => $MG_albums[$achild[$indexCounter]]->description == '' ? '' : PLG_replaceTags($MG_albums[$achild[$indexCounter]]->description, 'mediagallery', 'album_description'), 'album_media_count' => $album_media_count, 'subalbum_media_count' => $total_images_subalbums, 'album_owner' => $ownername, 'album_last_update' => $album_last_update[0], 'column_width' => $albumColumnWidth, 'column_width2' => $tn_height + 35 . 'px', 'lang_album' => $LANG_MG00['album'], 'border_width' => $newwidth + 20, 'border_height' => $newheight + 20, 'media_link_start' => '<a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$achild[$indexCounter]]->id . '&page=1' . '">', 'media_link_end' => '</a>', 'url_media_item' => $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$achild[$indexCounter]]->id . '&page=1', 'media_thumbnail' => $album_last_image, 'media_size' => 'width="' . $newwidth . '" height="' . $newheight . '"', 'media_height' => $newheight, 'media_width' => $newwidth, 'media_tag' => strip_tags($MG_albums[$achild[$indexCounter]]->title), 'frWidth' => $newwidth - $MG_albums[0]->afrWidth, 'frHeight' => $newheight - $MG_albums[0]->afrHeight)); $T->parse('AColumn', 'AlbumColumn', true); $indexCounter++; } if ($noParse == 1) { break; } else { $T->parse('ARow', 'AlbumRow', true); $T->set_var('AColumn', ''); } } } $T->set_var(array('bottom_pagination' => COM_printPageNavigation($_MG_CONF['site_url'] . '/index.php', $page + 1, ceil($aCount / $items_per_page)), 'table_columns' => $_MG_CONF['album_display_columns'])); if ($albumCount == 0) { $T->set_var(array('noitems' => $LANG_MG03['no_album_objects'])); $T->parse('gallery_noitems', 'noitems'); } else { $T->parse('gallery_body', 'body'); } $T->parse('output', 'page'); $nCSS = $nFrame->getCSS(); if ($nCSS != '') { $outputHandle = outputHandler::getInstance(); $outputHandle->addStyle($nCSS); } $display .= MG_siteHeader($LANG_MG00['plugin']); $display .= $T->finish($T->get_var('output')); $display .= MG_siteFooter(); echo $display; exit; }
/** * Delete an existing static page * * @param array args Contains all the data provided by the client * @param string &output OUTPUT parameter containing the returned text * @param string &svc_msg OUTPUT parameter containing any service messages * @return int Response code as defined in lib-plugins.php */ function service_delete_staticpages($args, &$output, &$svc_msg) { global $_CONF, $_TABLES, $_USER, $LANG_ACCESS, $LANG12, $LANG_STATIC, $LANG_LOGIN; if (empty($args['sp_id']) && !empty($args['id'])) { $args['sp_id'] = $args['id']; } // Apply filters to the parameters passed by the webservice if ($args['gl_svc']) { $args['sp_id'] = COM_applyBasicFilter($args['sp_id']); $args['mode'] = COM_applyBasicFilter($args['mode']); } $sp_id = $args['sp_id']; if (!SEC_hasRights('staticpages.delete')) { $output = COM_siteHeader('menu', $LANG_STATIC['access_denied']); $output .= COM_showMessageText($LANG_STATIC['access_denied_msg'], $LANG_STATIC['access_denied'], true); $output .= COM_siteFooter(); if (!COM_isAnonUser()) { return PLG_RET_PERMISSION_DENIED; } else { return PLG_RET_AUTH_FAILED; } } DB_delete($_TABLES['staticpage'], 'sp_id', $sp_id); DB_delete($_TABLES['comments'], array('sid', 'type'), array($sp_id, 'staticpages')); PLG_itemDeleted($sp_id, 'staticpages'); $output = COM_refresh($_CONF['site_admin_url'] . '/plugins/staticpages/index.php'); return PLG_RET_OK; }
/** * Get the payment gateway checkout buttons. * * @uses PaymentGw::CheckoutButton() * @return string HTML for checkout buttons */ public function getCheckoutButtons() { global $_PP_CONF; $gateway_vars = ''; if ($_PP_CONF['anon_buy'] || !COM_isAnonUser()) { PAYPAL_loadGateways(); foreach ($_PP_CONF['gateways'] as $gw_info) { if (!PaymentGw::Supports('checkout', $gw_info)) { continue; } $gw_name = $gw_info['id']; $gateway = new $gw_name(); $gateway_vars .= '<div class="paypalCheckoutButton">' . $gateway->CheckoutButton($this) . '</div>'; } } else { $L = new Template(PAYPAL_PI_PATH . '/templates/buttons'); $L->set_file('login', 'btn_login_req.thtml'); $L->parse('login_btn', 'login'); $gateway_vars = $L->finish($L->get_var('login_btn')); } return $gateway_vars; }
} else { $dt->setTimestamp($record['lastupdated']); $lastdate = $dt->format('M/d/y H:i a', true); $lastreply = $record; } $dt->setTimestamp($record['date']); $firstdate1 = $dt->format('m/d/Y', true); if ($dt->isToday()) { $firsttime = $dt->format('H:i a', true); $firstdate = $LANG_GF01['TODAY'] . $firsttime; } elseif ($_FF_CONF['allow_user_dateformat']) { $firstdate = $dt->format($dt->getUserFormat(), true); } else { $firstdate = $dt->format('M/d/y H:i a', true); } if (!COM_isAnonUser()) { // Determine if there are new topics since last visit for this user. // If topic has been updated or is new - then the user will not have record for this parent topic in the log table $sql = "SELECT * FROM {$_TABLES['ff_log']} WHERE uid=" . (int) $uid . " AND topic=" . (int) $record['id'] . " AND time > 0"; $lsql = DB_query($sql); if (DB_numRows($lsql) == 0) { if ($record['sticky'] == 1) { $folderimg = '<img src="' . _ff_getImage('sticky_new') . '" style="vertical-align:middle;" alt="' . $LANG_GF02['msg115'] . '" title="' . $LANG_GF02['msg115'] . '"/>'; $folder_icon = _ff_getImage('sticky_new'); $folder_msg = $LANG_GF02['msg115']; } elseif ($record['locked'] == 1) { $folderimg = '<img src="' . _ff_getImage('locked_new') . '" style="vertical-align:middle;" alt="' . $LANG_GF02['msg116'] . '" title="' . $LANG_GF02['msg116'] . '"/>'; $folder_icon = _ff_getImage('locked_new'); $folder_msg = $LANG_GF02['msg116']; } else { $folderimg = '<img src="' . _ff_getImage('newposts') . '" style="vertical-align:middle;" alt="' . $LANG_GF02['msg60'] . '" title="' . $LANG_GF02['msg60'] . '"/>';
COM_handle404(); exit; } //debug 時 true $_USERBOX_VERBOSE = false; // +---------------------------------------------------------------------------+ // MAIN // +---------------------------------------------------------------------------+ //############################ $pi_name = 'userbox'; //############################ // $display = ''; $page_title = $LANG_USERBOX_ADMIN['piname']; //ログイン要否チェック if (COM_isAnonUser()) { if ($_CONF['loginrequired'] or $_USERBOX_CONF['loginrequired'] == 3 or $_USERBOX_CONF['loginrequired'] == 2 and $id > 0) { $display .= DATABOX_siteHeader($pi_name, '', $page_title); $display .= SEC_loginRequiredForm(); $display .= DATABOX_siteFooter($pi_name); COM_output($display); exit; } } //引数 //public_html/download.php?id=1&field_id= $id = ''; if (isset($_REQUEST['id'])) { $id = COM_applyFilter($_REQUEST['id'], true); } $code = '';
/** * Do any other initialisation here */ function theme_init_modern_curve() { global $_BLOCK_TEMPLATE, $_CONF; /* * For left/right block support there is no longer any need for the theme to * put code into functions.php to set specific templates for the left/right * versions of blocks. Instead, Geeklog will automagically look for * blocktemplate-left.thtml and blocktemplate-right.thtml if given * blocktemplate.thtml from $_BLOCK_TEMPLATE. So, if you want different left * and right templates from admin_block, just create blockheader-list-left.thtml * etc. */ $_BLOCK_TEMPLATE['_msg_block'] = 'blockheader-message.thtml,blockfooter-message.thtml'; $_BLOCK_TEMPLATE['configmanager_block'] = 'blockheader-config.thtml,blockfooter-config.thtml'; $_BLOCK_TEMPLATE['configmanager_subblock'] = 'blockheader-config.thtml,blockfooter-config.thtml'; $_BLOCK_TEMPLATE['whats_related_block'] = 'blockheader-related.thtml,blockfooter-related.thtml'; $_BLOCK_TEMPLATE['story_options_block'] = 'blockheader-related.thtml,blockfooter-related.thtml'; // Define the blocks that are a list of links styled as an unordered list - using class="blocklist" $_BLOCK_TEMPLATE['admin_block'] = 'blockheader-list.thtml,blockfooter-list.thtml'; $_BLOCK_TEMPLATE['section_block'] = 'blockheader-list.thtml,blockfooter-list.thtml'; if (!COM_isAnonUser()) { $_BLOCK_TEMPLATE['user_block'] = 'blockheader-list.thtml,blockfooter-list.thtml'; } }
/** * Get a token's expiry time * * @param string $token the token we're looking for * @return int UNIX timestamp of the expiry time or 0 */ function SEC_getTokenExpiryTime($token) { global $_TABLES, $_USER; $retval = 0; if (!COM_isAnonUser()) { $sql['mysql'] = "SELECT UNIX_TIMESTAMP(DATE_ADD(created, INTERVAL ttl SECOND)) AS expirytime FROM {$_TABLES['tokens']} WHERE (token = '{$token}') AND (owner_id = '{$_USER['uid']}') AND (ttl > 0)"; $sql['pgsql'] = "SELECT UNIX_TIMESTAMP(created) + ttl AS expirytime FROM {$_TABLES['tokens']} WHERE (token = '{$token}') AND (owner_id = '{$_USER['uid']}') AND (ttl > 0)"; $result = DB_query($sql); if (DB_numRows($result) == 1) { list($retval) = DB_fetchArray($result); } } return $retval; }
/** * Kicks off the appropriate search(es) * * Initiates the search engine and returns HTML formatted * results. It also provides support to plugins using a * search API. * * @author Sami Barakat <s.m.barakat AT gmail DOT com> * @access public * @return string HTML output for search results * */ function doSearch() { global $_CONF, $LANG01, $LANG09, $LANG31, $_TABLES, $_USER; $debug_info = ''; $retval = ''; $list_top = ''; // Verify current user can perform requested search if (!$this->_isSearchAllowed()) { return $this->_getAccessDeniedMessage(); } // Make sure there is a query string // Full text searches have a minimum word length of 3 by default if (empty($this->_query)) { if ((empty($this->_author) || $this->_author == 0) && (empty($this->_type) || $this->_type == 'all') && (empty($this->_topic) || $this->_topic == 'all') && (empty($this->_dateStart) || empty($this->_dateEnd))) { $retval = $this->showForm(); $retval .= '<div style="margin-bottom:5px;border-bottom:1px solid #ccc;"></div><p>' . $LANG09[41] . '</p>' . LB; return $retval; } } elseif (strlen($this->_query) < 3) { $retval = $this->showForm(); $retval .= '<div style="margin-bottom:5px;border-bottom:1px solid #ccc;"></div><p>' . $LANG09[41] . '</p>' . LB; return $retval; } // Build the URL strings $this->_searchURL = $_CONF['site_url'] . '/search.php?query=' . urlencode($this->_query) . (!empty($this->_keyType) ? '&keyType=' . urlencode($this->_keyType) : '') . (!empty($this->_dateStart) ? '&datestart=' . urlencode($this->_dateStart) : '') . (!empty($this->_dateEnd) ? '&dateend=' . urlencode($this->_dateEnd) : '') . (!empty($this->_topic) ? '&topic=' . urlencode($this->_topic) : '') . (!empty($this->_author) ? '&author=' . urlencode($this->_author) : '') . (!empty($this->_searchDays) ? '&st=' . urlencode($this->_searchDays) : ''); $url = "{$this->_searchURL}&type={$this->_type}&mode="; $obj = new ListFactory($url . 'search', $_CONF['search_limits'], $_CONF['num_search_results']); $obj->setField('ID', 'id', false); $obj->setField('URL', 'url', false); $show_num = $_CONF['search_show_num']; $show_type = $_CONF['search_show_type']; $show_user = $_CONF['search_show_user']; $show_hits = $_CONF['search_show_hits']; $style = isset($_CONF['search_style']) ? $_CONF['search_style'] : 'google'; if (!COM_isAnonUser()) { $userStyle = DB_getItem($_TABLES['userprefs'], 'search_result_format', 'uid=' . (int) $_USER['uid']); if ($userStyle != '') { $style = $userStyle; } } if ($style == 'table') { $obj->setStyle('table'); // Title Name Display Sort Format $obj->setField($LANG09[62], ROW_NUMBER, $show_num, false, '<b>%d.</b>'); $obj->setField($LANG09[5], SQL_TITLE, $show_type, true, '<b>%s</b>'); $obj->setField($LANG09[16], 'title', true, true); $obj->setField($LANG09[63], 'description', true, false); $obj->setField($LANG09[17], 'date', true, true); $obj->setField($LANG09[18], 'uid', $show_user, true); $obj->setField($LANG09[50], 'hits', $show_hits, true); $this->_wordlength = 7; } else { if ($style == 'google') { $obj->setStyle('inline'); $obj->setField('', ROW_NUMBER, $show_num, false, '<span style="font-size:larger; font-weight:bold;">%d.</span>'); $obj->setField($LANG09[16], 'title', true, true, '<span style="font-size:larger; font-weight:bold;">%s</span><br/>'); $obj->setField('', 'description', true, false, '%s<br/>'); $obj->setField('', '_html', true, false, '<span style="color:green;">'); $obj->setField($LANG09[18], 'uid', $show_user, true, $LANG01[104] . ' %s '); $obj->setField($LANG09[17], 'date', true, true, $LANG01[36] . ' %s'); $obj->setField($LANG09[5], SQL_TITLE, $show_type, true, ' - %s'); $obj->setField($LANG09[50], 'hits', $show_hits, true, ' - %s ' . $LANG09[50]); $obj->setField('', '_html', true, false, '</span>'); $this->_wordlength = 50; } } $obj->setDefaultSort('date'); $obj->setRowFunction(array($this, 'searchFormatCallBack')); // Start search timer $searchtimer = new timerobject(); $searchtimer->setPercision(4); $searchtimer->startTimer(); // Have plugins do their searches $page = isset($_REQUEST['page']) ? COM_applyFilter($_REQUEST['page'], true) : 1; $result_plugins = PLG_doSearch($this->_query, $this->_dateStart, $this->_dateEnd, $this->_topic, $this->_type, $this->_author, $this->_keyType, $page, 5); $result_plugins_comment = PLG_doSearchComment($this->_query, $this->_dateStart, $this->_dateEnd, $this->_topic, $this->_type, $this->_author, $this->_keyType, $page, 5); $result_plugins = array_merge($result_plugins, $result_plugins_comment); // Add core searches if ($this->_type == 'all' || $this->_type == 'stories') { $result_plugins[] = $this->_searchStories(); } if ($this->_type == 'all' || $this->_type == 'comments') { $result_plugins[] = $this->_searchComments(); } // Loop through all plugins separating the new API from the old $new_api = 0; $old_api = 0; $num_results = 0; if (!isset($_CONF['search_use_fulltext'])) { $_CONF['search_use_fulltext'] = false; } foreach ($result_plugins as $result) { if (is_a($result, 'SearchCriteria')) { $debug_info .= $result->getName() . " using APIv2, "; $type = $result->getType(); if ($type == 'sql') { if ($_CONF['search_use_fulltext'] == true && $result->getFTSQL() != '') { $debug_info .= "search using FULLTEXT\n"; $sql = $result->getFTSQL(); } else { $debug_info .= "search using LIKE\n"; $sql = $result->getSQL(); } $sql = $this->_convertsql($sql); $obj->setQuery($result->getLabel(), $result->getName(), $sql, $result->getRank()); $this->_url_rewrite[$result->getName()] = $result->UrlRewriteEnable() ? true : false; } else { if ($type == 'text') { $obj->setQueryText($result->getLabel(), $result->getName(), $this->_query, $result->getNumResults(), $result->getRank()); } } $new_api++; } else { if (is_a($result, 'Plugin') && $result->num_searchresults != 0) { // Some backwards compatibility $debug_info .= $result->plugin_name . " using APIv1, search using backwards compatibility\n"; // Find the column heading names that closely match what we are looking for // There may be issues here on different languages, but this _should_ capture most of the data $col_title = $this->_findColumn($result->searchheading, array($LANG09[16], $LANG31[4], 'Question')); //Title,Subject $col_desc = $this->_findColumn($result->searchheading, array($LANG09[63], 'Answer')); $col_date = $this->_findColumn($result->searchheading, array($LANG09[17])); //'Date','Date Added','Last Updated','Date & Time' $col_user = $this->_findColumn($result->searchheading, array($LANG09[18], 'Submited by')); $col_hits = $this->_findColumn($result->searchheading, array($LANG09[50], $LANG09[23], 'Downloads', 'Clicks')); //'Hits','Views' $col_url = $this->_findColumn($result->searchheading, array('URL')); //'Hits','Views' $label = str_replace($LANG09[59], '', $result->searchlabel); if ($result->num_itemssearched > 0) { $_page = isset($_REQUEST['page']) ? COM_applyFilter($_REQUEST['page'], true) : 1; if (isset($_REQUEST['results'])) { $_per_page = COM_applyFilter($_REQUEST['results'], true); } else { $_per_page = $obj->getPerPage(); } $obj->addTotalRank(3); $pp = round(3 / $obj->getTotalRank() * $_per_page); $offset = ($_page - 1) * $pp; $limit = $pp; $obj->addToTotalFound($result->num_itemssearched); $counter = 0; // Extract the results foreach ($result->searchresults as $old_row) { if ($counter >= $offset && $counter <= $offset + $limit) { if ($col_date != -1) { // Convert the date back to a timestamp $date = $old_row[$col_date]; $date = substr($date, 0, strpos($date, '@')); if ($date == '') { $date = $old_row[$col_date]; } else { $date = strtotime($date); } } $api_results = array(SQL_NAME => $result->plugin_name, SQL_TITLE => $label, 'title' => $col_title == -1 ? $_CONF['search_no_data'] : $old_row[$col_title], 'description' => $col_desc == -1 ? $_CONF['search_no_data'] : $old_row[$col_desc], 'date' => $col_date == -1 ? ' ' : $date, 'uid' => $col_user == -1 ? '' : $old_row[$col_user], 'hits' => $col_hits == -1 ? '0' : str_replace(',', '', $old_row[$col_hits]), 'url' => $old_row[$col_url]); $obj->addResult($api_results); } $counter++; } } $old_api++; } } } // Find out how many plugins are on the old/new system $debug_info .= "\nAPIv1: {$old_api}\nAPIv2: {$new_api}"; // Execute the queries $results = $obj->ExecuteQueries(); // Searches are done, stop timer $searchtime = $searchtimer->stopTimer(); $escquery = htmlspecialchars($this->_query); if ($this->_keyType == 'any') { $searchQuery = str_replace(' ', "</b>' " . $LANG09[57] . " '<b>", $escquery); $searchQuery = "<b>'{$searchQuery}'</b>"; } else { if ($this->_keyType == 'all') { $searchQuery = str_replace(' ', "</b>' " . $LANG09[56] . " '<b>", $escquery); $searchQuery = "<b>'{$searchQuery}'</b>"; } else { $searchQuery = $LANG09[55] . " '<b>{$escquery}</b>'"; } } // Clean the query string so that sprintf works as expected $searchQuery = str_replace("%", "%%", $searchQuery); $searchText = "{$LANG09[25]} {$searchQuery}. "; $retval .= $this->showForm(); if (count($results) == 0) { $retval .= '<div style="margin-bottom:5px;border-bottom:1px solid #ccc;"></div>'; $retval .= $LANG09[74]; } else { $retval .= $obj->getFormattedOutput($results, $LANG09[11], $list_top, ''); } return $retval; }
/** * Shows a profile for a user * * This grabs the user profile for a given user and displays it * * @return string HTML for user profile page * */ function userprofile() { global $_CONF, $_TABLES, $_USER, $LANG01, $LANG04, $LANG09, $LANG28, $LANG_LOGIN; // @param int $user User ID of profile to get // @param int $msg Message to display (if != 0) // @param string $plugin optional plugin name for message $retval = ''; if (COM_isAnonUser() && ($_CONF['loginrequired'] == 1 || $_CONF['profileloginrequired'] == 1)) { $retval .= SEC_loginRequiredForm(); return $retval; } if (isset($_GET['uid'])) { $user = COM_applyFilter($_GET['uid'], true); if (!is_numeric($user) || $user < 2) { echo COM_refresh($_CONF['site_url'] . '/index.php'); } } else { if (isset($_GET['username'])) { $username = $_GET['username']; if (!USER_validateUsername($username, 1)) { echo COM_refresh($_CONF['site_url'] . '/index.php'); } if (empty($username) || $username == '') { echo COM_refresh($_CONF['site_url'] . '/index.php'); } $username = DB_escapeString($username); $user = DB_getItem($_TABLES['users'], 'uid', "username = '******'"); if ($user < 2) { echo COM_refresh($_CONF['site_url'] . '/index.php'); } } else { echo COM_refresh($_CONF['site_url'] . '/index.php'); } } $msg = 0; if (isset($_GET['msg'])) { $msg = COM_applyFilter($_GET['msg'], true); } $plugin = ''; if ($msg > 0 && isset($_GET['plugin'])) { $plugin = COM_applyFilter($_GET['plugin']); } $result = DB_query("SELECT {$_TABLES['users']}.uid,username,fullname,regdate,lastlogin,homepage,about,location,pgpkey,photo,email,status,emailfromadmin,emailfromuser,showonline FROM {$_TABLES['userinfo']},{$_TABLES['userprefs']},{$_TABLES['users']} WHERE {$_TABLES['userinfo']}.uid = {$_TABLES['users']}.uid AND {$_TABLES['userinfo']}.uid = {$_TABLES['userprefs']}.uid AND {$_TABLES['users']}.uid = " . (int) $user); $nrows = DB_numRows($result); if ($nrows == 0) { // no such user echo COM_refresh($_CONF['site_url'] . '/index.php'); } $A = DB_fetchArray($result); if ($A['status'] == USER_ACCOUNT_DISABLED && !SEC_hasRights('user.edit')) { COM_displayMessageAndAbort(30, '', 403, 'Forbidden'); } $display_name = @htmlspecialchars(COM_getDisplayName($user, $A['username'], $A['fullname']), ENT_COMPAT, COM_getEncodingt()); if ($msg > 0) { $retval .= COM_showMessage($msg, $plugin, '', 0, 'info'); } // format date/time to user preference $curtime = COM_getUserDateTimeFormat($A['regdate']); $A['regdate'] = $curtime[0]; $user_templates = new Template($_CONF['path_layout'] . 'users'); $user_templates->set_file(array('profile' => 'profile.thtml', 'email' => 'email.thtml', 'row' => 'commentrow.thtml', 'strow' => 'storyrow.thtml')); $user_templates->set_var('layout_url', $_CONF['layout_url']); $user_templates->set_var('start_block_userprofile', COM_startBlock($LANG04[1] . ' ' . $display_name)); $user_templates->set_var('end_block', COM_endBlock()); $user_templates->set_var('lang_username', $LANG04[2]); $user_templates->set_var('tooltip', COM_getTooltipStyle()); if ($_CONF['show_fullname'] == 1) { if (empty($A['fullname'])) { $username = $A['username']; $fullname = ''; } else { $username = $A['fullname']; $fullname = $A['username']; } } else { $username = $A['username']; $fullname = ''; } $username = @htmlspecialchars($username, ENT_COMPAT, COM_getEncodingt()); $fullname = @htmlspecialchars($fullname, ENT_COMPAT, COM_getEncodingt()); if ($A['status'] == USER_ACCOUNT_DISABLED) { $username = sprintf('%s - %s', $username, $LANG28[42]); if (!empty($fullname)) { $fullname = sprintf('% - %s', $fullname, $LANG28[42]); } } $user_templates->set_var('username', $username); $user_templates->set_var('user_fullname', $fullname); if (SEC_hasRights('user.edit') || isset($_USER['uid']) && $_USER['uid'] == $A['uid']) { global $_IMAGE_TYPE, $LANG_ADMIN; $edit_icon = '<img src="' . $_CONF['layout_url'] . '/images/edit.' . $_IMAGE_TYPE . '" alt="' . $LANG_ADMIN['edit'] . '" title="' . $LANG_ADMIN['edit'] . '" />'; if ($_USER['uid'] == $A['uid']) { $edit_url = "{$_CONF['site_url']}/usersettings.php"; } else { $edit_url = "{$_CONF['site_admin_url']}/user.php?edit=x&uid={$A['uid']}"; } $edit_link_url = COM_createLink($edit_icon, $edit_url); $user_templates->set_var('edit_icon', $edit_icon); $user_templates->set_var('edit_link', $edit_link_url); $user_templates->set_var('user_edit', $edit_url); } else { $user_templates->set_var('user_edit', ''); } if (isset($A['photo']) && empty($A['photo'])) { $A['photo'] = '(none)'; // user does not have a photo } $lastlogin = $A['lastlogin']; $lasttime = COM_getUserDateTimeFormat($lastlogin); $photo = USER_getPhoto($user, $A['photo'], $A['email'], -1, 0); $user_templates->set_var('user_photo', $photo); $user_templates->set_var('lang_membersince', $LANG04[67]); $user_templates->set_var('user_regdate', $A['regdate']); if ($_CONF['lastlogin'] && $A['showonline']) { $user_templates->set_var('lang_lastlogin', $LANG28[35]); if (!empty($lastlogin)) { $user_templates->set_var('user_lastlogin', $lasttime[0]); } else { $user_templates->set_var('user_lastlogin', $LANG28[36]); } } if ($A['showonline']) { if (DB_count($_TABLES['sessions'], 'uid', (int) $user)) { $user_templates->set_var('online', 'online'); } } $user_templates->set_var('lang_email', $LANG04[5]); $user_templates->set_var('user_id', $user); if ($A['email'] == '' || $A['emailfromuser'] == 0) { $user_templates->set_var('email_option', ''); } else { $user_templates->set_var('lang_sendemail', $LANG04[81]); $user_templates->parse('email_option', 'email', true); } $user_templates->set_var('lang_homepage', $LANG04[6]); $user_templates->set_var('user_homepage', COM_killJS($A['homepage'])); $user_templates->set_var('lang_location', $LANG04[106]); $user_templates->set_var('user_location', strip_tags($A['location'])); $user_templates->set_var('lang_online', $LANG04[160]); $user_templates->set_var('lang_bio', $LANG04[7]); $user_templates->set_var('user_bio', nl2br($A['about'])); $user_templates->set_var('follow_me', SOC_getFollowMeIcons($user, 'follow_user_profile.thtml')); $user_templates->set_var('lang_pgpkey', $LANG04[8]); $user_templates->set_var('user_pgp', nl2br($A['pgpkey'])); $user_templates->set_var('start_block_last10stories', COM_startBlock($LANG04[82] . ' ' . $display_name)); if (!isset($_CONF['comment_engine']) || $_CONF['comment_engine'] == 'internal') { $user_templates->set_var('start_block_last10comments', COM_startBlock($LANG04[10] . ' ' . $display_name)); } $user_templates->set_var('start_block_postingstats', COM_startBlock($LANG04[83] . ' ' . $display_name)); $user_templates->set_var('lang_title', $LANG09[16]); $user_templates->set_var('lang_date', $LANG09[17]); // for alternative layouts: use these as headlines instead of block titles $user_templates->set_var('headline_last10stories', $LANG04[82] . ' ' . $display_name); if (!isset($_CONF['comment_engine']) || $_CONF['comment_engine'] == 'internal') { $user_templates->set_var('headline_last10comments', $LANG04[10] . ' ' . $display_name); } $user_templates->set_var('headline_postingstats', $LANG04[83] . ' ' . $display_name); $result = DB_query("SELECT tid FROM {$_TABLES['topics']}" . COM_getPermSQL()); $nrows = DB_numRows($result); $tids = array(); for ($i = 0; $i < $nrows; $i++) { $T = DB_fetchArray($result); $tids[] = $T['tid']; } $topics = "'" . implode("','", $tids) . "'"; // list of last 10 stories by this user if (sizeof($tids) > 0) { $sql = "SELECT sid,title,UNIX_TIMESTAMP(date) AS unixdate FROM {$_TABLES['stories']} WHERE (uid = '" . (int) $user . "') AND (draft_flag = 0) AND (date <= NOW()) AND (tid IN ({$topics}))" . COM_getPermSQL('AND'); $sql .= " ORDER BY unixdate DESC LIMIT 10"; $result = DB_query($sql); $nrows = DB_numRows($result); } else { $nrows = 0; } if ($nrows > 0) { for ($i = 0; $i < $nrows; $i++) { $C = DB_fetchArray($result); $user_templates->set_var('cssid', $i % 2 + 1); $user_templates->set_var('row_number', $i + 1 . '.'); $articleUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $C['sid']); $user_templates->set_var('article_url', $articleUrl); $C['title'] = str_replace('$', '$', $C['title']); $user_templates->set_var('story_title', COM_createLink($C['title'], $articleUrl, array('class' => ''))); $storytime = COM_getUserDateTimeFormat($C['unixdate']); $user_templates->set_var('story_date', $storytime[0]); $user_templates->parse('story_row', 'strow', true); } } else { $user_templates->set_var('story_row', '<tr><td>' . $LANG01[37] . '</td></tr>'); } if (!isset($_CONF['comment_engine']) || $_CONF['comment_engine'] == 'internal') { // list of last 10 comments by this user $sidArray = array(); if (sizeof($tids) > 0) { // first, get a list of all stories the current visitor has access to $sql = "SELECT sid FROM {$_TABLES['stories']} WHERE (draft_flag = 0) AND (date <= NOW()) AND (tid IN ({$topics}))" . COM_getPermSQL('AND'); $result = DB_query($sql); $numsids = DB_numRows($result); for ($i = 1; $i <= $numsids; $i++) { $S = DB_fetchArray($result); $sidArray[] = $S['sid']; } } $sidList = implode("', '", $sidArray); $sidList = "'{$sidList}'"; // then, find all comments by the user in those stories $sql = "SELECT sid,title,cid,UNIX_TIMESTAMP(date) AS unixdate FROM {$_TABLES['comments']} WHERE (uid = '" . (int) $user . "') GROUP BY sid,title,cid,UNIX_TIMESTAMP(date)"; // SQL NOTE: Using a HAVING clause is usually faster than a where if the // field is part of the select // if (!empty ($sidList)) { // $sql .= " AND (sid in ($sidList))"; // } if (!empty($sidList)) { $sql .= " HAVING sid in ({$sidList})"; } $sql .= " ORDER BY unixdate DESC LIMIT 10"; $result = DB_query($sql); $nrows = DB_numRows($result); if ($nrows > 0) { for ($i = 0; $i < $nrows; $i++) { $C = DB_fetchArray($result); $user_templates->set_var('cssid', $i % 2 + 1); $user_templates->set_var('row_number', $i + 1 . '.'); $C['title'] = str_replace('$', '$', $C['title']); $comment_url = $_CONF['site_url'] . '/comment.php?mode=view&cid=' . $C['cid']; $user_templates->set_var('comment_title', COM_createLink($C['title'], $comment_url, array('class' => ''))); $commenttime = COM_getUserDateTimeFormat($C['unixdate']); $user_templates->set_var('comment_date', $commenttime[0]); $user_templates->parse('comment_row', 'row', true); } } else { $user_templates->set_var('comment_row', '<tr><td>' . $LANG01[29] . '</td></tr>'); } } // posting stats for this user $user_templates->set_var('lang_number_stories', $LANG04[84]); $sql = "SELECT COUNT(*) AS count FROM {$_TABLES['stories']} WHERE (uid = " . (int) $user . ") AND (draft_flag = 0) AND (date <= NOW())" . COM_getPermSQL('AND'); $result = DB_query($sql); $N = DB_fetchArray($result); $user_templates->set_var('number_stories', COM_numberFormat($N['count'])); if (!isset($_CONF['comment_engine']) || $_CONF['comment_engine'] == 'internal') { $user_templates->set_var('lang_number_comments', $LANG04[85]); $sql = "SELECT COUNT(*) AS count FROM {$_TABLES['comments']} WHERE (uid = " . (int) $user . ")"; if (!empty($sidList)) { $sql .= " AND (sid in ({$sidList}))"; } $result = DB_query($sql); $N = DB_fetchArray($result); $user_templates->set_var('number_comments', COM_numberFormat($N['count'])); $user_templates->set_var('lang_all_postings_by', $LANG04[86] . ' ' . $display_name); } // hook to the profile icon display $profileIcons = PLG_profileIconDisplay($user); if (is_array($profileIcons) && count($profileIcons) > 0) { $user_templates->set_block('profile', 'profileicon', 'pi'); for ($x = 0; $x < count($profileIcons); $x++) { if (isset($profileIcons[$x]['url']) && $profileIcons[$x]['url'] != '' && isset($profileIcons[$x]['icon']) && $profileIcons[$x]['icon'] != '') { $user_templates->set_var('profile_icon_url', $profileIcons[$x]['url']); $user_templates->set_var('profile_icon_icon', $profileIcons[$x]['icon']); $user_templates->set_var('profile_icon_text', $profileIcons[$x]['text']); $user_templates->parse('pi', 'profileicon', true); } } } // Call custom registration function if enabled and exists if ($_CONF['custom_registration'] && function_exists('CUSTOM_userDisplay')) { $user_templates->set_var('customfields', CUSTOM_userDisplay($user)); } PLG_profileVariablesDisplay($user, $user_templates); $user_templates->parse('output', 'profile'); $retval .= $user_templates->finish($user_templates->get_var('output')); $retval .= PLG_profileBlocksDisplay($user); return $retval; }