Example #1
0
 /**
  *   Display the detail page for the product.
  *
  *   @return string      HTML for the product page.
  */
 public function Detail()
 {
     global $_CONF, $_PP_CONF, $_TABLES, $LANG_PP, $_USER;
     USES_lib_comments();
     $prod_id = $this->id;
     if ($prod_id < 1 || !$this->enabled) {
         return PAYPAL_errorMessage($LANG_PP['invalid_product_id'], 'info');
     }
     $retval = COM_startBlock();
     // Set the template dir based on the configured template version
     $T = new Template(PAYPAL_PI_PATH . '/templates/detail' . $_PP_CONF['tpl_ver_detail']);
     if ($this->hasAttributes()) {
         $detail_template = 'product_detail_attrib.thtml';
     } else {
         $detail_template = 'product_detail.thtml';
     }
     $T->set_file('product', $detail_template);
     $name = $this->name;
     $l_desc = PLG_replaceTags($this->description);
     $s_desc = PLG_replaceTags($this->short_description);
     // Highlight the query terms if coming from a search
     if (isset($_REQUEST['query']) && !empty($_REQUEST['query'])) {
         $name = COM_highlightQuery($name, $_REQUEST['query']);
         $l_desc = COM_highlightQuery($l_desc, $_REQUEST['query']);
         $s_desc = COM_highlightQuery($s_desc, $_REQUEST['query']);
     }
     $act_price = $this->sale_price == $this->price ? $this->price : $this->sale_price;
     $T->set_var(array('id' => $prod_id, 'name' => $name, 'short_description' => $s_desc, 'description' => $l_desc, 'cur_decimals' => $this->currency->Decimals(), 'price' => $this->currency->FormatValue($act_price), 'orig_price' => $this->currency->Format($this->price), 'on_sale' => $act_price == $this->price ? '' : 'true', 'img_cell_width' => $_PP_CONF['max_thumb_size'] + 20, 'price_prefix' => $this->currency->Pre(), 'price_postfix' => $this->currency->Post(), 'onhand' => $this->track_onhand ? $this->onhand : ''));
     // Retrieve the photos and put into the template
     $sql = "SELECT img_id, filename\n                FROM {$_TABLES['paypal.images']} \n                WHERE product_id='{$prod_id}'";
     //echo $sql;die;
     $img_res = DB_query($sql);
     $photo_detail = '';
     $T->set_var('have_photo', '');
     // assume no photo available
     if ($img_res && DB_numRows($img_res) > 0) {
         for ($i = 0; $prow = DB_fetchArray($img_res, false); $i++) {
             if ($prow['filename'] != '' && file_exists("{$_PP_CONF['image_dir']}/{$prow['filename']}")) {
                 if ($i == 0) {
                     $T->set_var('main_img', $prow['filename']);
                 }
                 $T->set_block('product', 'Thumbnail', 'PBlock');
                 $T->set_var('img_file', $prow['filename']);
                 $T->set_var('img_url', PAYPAL_URL . '/images/products');
                 $T->set_var('thumb_url', PAYPAL_ImageUrl($prow['filename']));
                 $T->parse('PBlock', 'Thumbnail', true);
                 $T->set_var('have_photo', 'true');
             }
         }
     }
     // Get the product options, if any, and set them into the form
     $i = 0;
     $cbrk = '';
     $attributes = '';
     foreach ($this->options as $id => $Attr) {
         if ($Attr['attr_name'] != $cbrk) {
             if ($i > 0) {
                 $attributes .= "</select></td></tr>\n";
             } else {
                 $attributes = '<table border="0">' . "\n";
             }
             $cbrk = $Attr['attr_name'];
             $attributes .= "<tr><td>\n                    <input type=\"hidden\" name=\"on{$i}\" \n                    value=\"{$Attr['attr_name']}\">\n\n                    <input type=\"hidden\" name=\"os{$i}\" \n                    value=\"\">\n\n                    {$Attr['attr_name']}:</td>\n                    <td align=\"left\">\n                    <select name=\"options[]\"\n                    onchange=\"ProcessForm(this.form);\">\n";
             /*<td align=\"left\"><select name=\"pp_os{$i}\"*/
             $i++;
         }
         if ($Attr['attr_price'] != 0) {
             $attr_str = sprintf(" ( %+.2f )", $Attr['attr_price']);
         } else {
             $attr_str = '';
         }
         $attributes .= '<option value="' . $id . '|' . $Attr['attr_value'] . '|' . $Attr['attr_price'] . '">' . $Attr['attr_value'] . $attr_str . '</option>' . LB;
     }
     if ($attributes != '') {
         $attributes .= "</select></td></tr></table>\n";
         $T->set_var('attributes', $attributes);
     }
     $buttons = $this->PurchaseLinks();
     $T->set_block('product', 'BtnBlock', 'Btn');
     foreach ($buttons as $name => $html) {
         $T->set_var('button', $html);
         $T->parse('Btn', 'BtnBlock', true);
     }
     // Show the user comments if enabled globally and for this product
     if (plugin_commentsupport_paypal() && $this->comments_enabled != PP_COMMENTS_DISABLED) {
         // if enabled or closed
         if ($_CONF['commentsloginrequired'] == 1 && COM_isAnonUser()) {
             // Set mode to "disabled"
             $mode = -1;
         } else {
             $mode = $this->comments_enabled;
         }
         $T->set_var('usercomments', CMT_userComments($prod_id, $this->short_description, 'paypal', '', '', 0, 1, false, false, $mode));
     }
     if ($this->rating_enabled == 1) {
         $PP_ratedIds = RATING_getRatedIds('paypal');
         if (in_array($prod_id, $PP_ratedIds)) {
             $static = true;
             $voted = 1;
         } elseif (plugin_canuserrate_paypal($A['id'], $_USER['uid'])) {
             $static = 0;
             $voted = 0;
         } else {
             $static = 1;
             $voted = 0;
         }
         $rating_box = RATING_ratingBar('paypal', $prod_id, $this->votes, $this->rating, $voted, 5, $static, 'sm');
         $T->set_var('rating_bar', $rating_box);
     } else {
         $T->set_var('ratign_bar', '');
     }
     if ($this->isAdmin) {
         // Add the quick-edit link for administrators
         $T->set_var(array('pi_admin_url' => PAYPAL_ADMIN_URL, 'can_edit' => 'true'));
     }
     $retval .= $T->parse('output', 'product');
     // Update the hit counter
     DB_query("UPDATE {$_TABLES['paypal.products']}\n                SET views = views + 1\n                WHERE id = '{$prod_id}'");
     $retval .= COM_endBlock();
     return $retval;
 }
Example #2
0
 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&amp;s=1&amp;album_id=' . $this->album_id . '&amp;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' . '&amp;sort=' . $sortOrder . '&amp;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&amp;s=1&amp;album_id=' . $this->album_id . '&amp;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('$', '&#36;', $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&amp;swhere=1&amp;keywords=' . $searchKeyword . '&amp;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' . '&amp;sort=' . $sortOrder . '&amp;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' . '&amp;sort=' . $sortOrder . '&amp;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;
 }
Example #3
0
 /**
  * Callback function for the ListFactory class
  *
  * This function gets called by the ListFactory class and formats
  * each row accordingly for example pulling usernames from the
  * users table and displaying a link to their profile.
  *
  * @param array $row An array of plain data to format
  * @return array A reformatted version of the input array
  *
  */
 public function searchFormatCallback($preSort, $row)
 {
     global $_CONF, $LANG09;
     if ($preSort) {
         if (is_array($row[LF_SOURCE_TITLE])) {
             $row[LF_SOURCE_TITLE] = implode($_CONF['search_separator'], $row[LF_SOURCE_TITLE]);
         }
         if (is_numeric($row['uid'])) {
             if (empty($this->_names[$row['uid']])) {
                 $this->_names[$row['uid']] = htmlspecialchars(COM_getDisplayName($row['uid']));
                 if ($row['uid'] != 1) {
                     $this->_names[$row['uid']] = COM_createLink($this->_names[$row['uid']], $_CONF['site_url'] . '/users.php?mode=profile&amp;uid=' . $row['uid']);
                 }
             }
             $row['uid'] = $this->_names[$row['uid']];
         }
     } else {
         $row[LF_SOURCE_TITLE] = COM_createLink($row[LF_SOURCE_TITLE], $this->_searchURL . '&amp;type=' . $row[LF_SOURCE_NAME] . '&amp;mode=search');
         if ($row['url'] != '#') {
             $row['url'] = ($row['url'][0] == '/' ? $_CONF['site_url'] : '') . $row['url'];
             if (isset($this->_url_rewrite[$row[LF_SOURCE_NAME]]) && $this->_url_rewrite[$row[LF_SOURCE_NAME]]) {
                 $row['url'] = COM_buildUrl($row['url']);
             }
             if (isset($this->_append_query[$row[LF_SOURCE_NAME]]) && $this->_append_query[$row[LF_SOURCE_NAME]]) {
                 if (!empty($this->_query)) {
                     $row['url'] .= (strpos($row['url'], '?') ? '&amp;' : '?') . 'query=' . urlencode($this->_query);
                 }
             }
         }
         $row['title'] = $this->_shortenText($this->_query, $row['title'], 8);
         $row['title'] = stripslashes(str_replace('$', '&#36;', $row['title']));
         $row['title'] = COM_createLink($row['title'], $row['url']);
         if ($row['description'] == 'LF_NULL') {
             $row['description'] = '<i>' . $LANG09[70] . '</i>';
         } elseif ($row['description'] != '<i>' . $LANG09[70] . '</i>') {
             $row['description'] = stripslashes($this->_shortenText($this->_query, PLG_replaceTags($row['description']), $this->_wordlength));
         }
         if ($row['date'] != 'LF_NULL') {
             $dt = COM_getUserDateTimeFormat(intval($row['date']));
             $row['date'] = $dt[0];
         }
         if ($row['hits'] != 'LF_NULL') {
             $row['hits'] = COM_NumberFormat($row['hits']) . ' ';
             // simple solution to a silly problem!
         }
     }
     return $row;
 }
Example #4
0
/**
* Adds an event to the user's calendar
*
* The user has asked that an event be added to their personal
* calendar.  Show a confirmation screen.
*
* @param    string  $eid    event ID to add to user's calendar
* @return   string          HTML for confirmation form
*
*/
function adduserevent($eid)
{
    global $_CONF, $_TABLES, $LANG_CALJP_1;
    $retval = '';
    $eventsql = "SELECT * FROM {$_TABLES['eventsjp']} WHERE eid='{$eid}'" . COM_getPermSql('AND');
    $result = DB_query($eventsql);
    $nrows = DB_numRows($result);
    if ($nrows == 1) {
        $retval .= COM_startBlock(sprintf($LANG_CALJP_1[11], COM_getDisplayName()));
        $A = DB_fetchArray($result);
        $cal_template = COM_newTemplate($_CONF['path'] . 'plugins/calendarjp/templates/');
        $cal_template->set_file(array('addevent' => 'addevent.thtml'));
        $cal_template->set_var('intro_msg', $LANG_CALJP_1[8]);
        $cal_template->set_var('lang_event', $LANG_CALJP_1[12]);
        $event_title = stripslashes($A['title']);
        if (!empty($A['url']) && $A['url'] != 'http://') {
            $event_title_and_url = COM_createLink($event_title, $A['url'], array('class' => 'url'));
            $cal_template->set_var('event_url', $A['url']);
            $cal_template->set_var('event_begin_anchortag', '<a href="' . $A['url'] . '" class="url">');
            $cal_template->set_var('event_end_anchortag', '</a>');
        } else {
            $event_title_and_url = $event_title;
            $cal_template->set_var('event_url', '');
            $cal_template->set_var('event_begin_anchortag', '');
            $cal_template->set_var('event_end_anchortag', '');
        }
        $cal_template->set_var('event_title', $event_title_and_url);
        $cal_template->set_var('event_title_only', $event_title);
        $cal_template->set_var('lang_starts', $LANG_CALJP_1[13]);
        $cal_template->set_var('lang_ends', $LANG_CALJP_1[14]);
        $thestart = COM_getUserDateTimeFormat($A['datestart'] . ' ' . $A['timestart']);
        $theend = COM_getUserDateTimeFormat($A['dateend'] . ' ' . $A['timeend']);
        if ($A['allday'] == 0) {
            $cal_template->set_var('event_start', $thestart[0]);
            $cal_template->set_var('event_end', $theend[0]);
        } else {
            $cal_template->set_var('event_start', strftime($_CONF['shortdate'], $thestart[1]));
            $cal_template->set_var('event_end', strftime($_CONF['shortdate'], $theend[1]));
        }
        $cal_template->set_var('lang_where', $LANG_CALJP_1[4]);
        $location = stripslashes($A['location']) . '<br' . XHTML . '>' . stripslashes($A['address1']) . '<br' . XHTML . '>' . stripslashes($A['address2']) . '<br' . XHTML . '>' . stripslashes($A['city']) . ', ' . stripslashes($A['state']) . ' ' . $A['zipcode'];
        $cal_template->set_var('event_location', $location);
        $cal_template->set_var('lang_description', $LANG_CALJP_1[5]);
        $description = stripslashes($A['description']);
        if (empty($A['postmode']) || $A['postmode'] == 'plaintext') {
            $description = COM_nl2br($description);
        }
        $cal_template->set_var('event_description', PLG_replaceTags($description));
        $cal_template->set_var('event_id', $eid);
        $cal_template->set_var('lang_addtomycalendar', $LANG_CALJP_1[9]);
        $cal_template->set_var('gltoken_name', CSRF_TOKEN);
        $cal_template->set_var('gltoken', SEC_createToken());
        $cal_template->parse('output', 'addevent');
        $retval .= $cal_template->finish($cal_template->get_var('output'));
        $retval .= COM_endBlock();
    } else {
        $retval .= COM_showMessage(23);
    }
    return $retval;
}
Example #5
0
/**
 * Get 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_get_staticpages($args, &$output, &$svc_msg)
{
    global $_CONF, $_TABLES, $LANG_ACCESS, $LANG12, $LANG_STATIC, $_SP_CONF;
    $output = '';
    $svc_msg['output_fields'] = array('sp_hits', 'sp_format', 'draft_flag', 'owner_id', 'group_id', 'perm_owner', 'perm_group', 'perm_members', 'perm_anon', 'sp_help', 'sp_php', 'sp_inblock', 'commentcode');
    if (empty($args['sp_id']) && !empty($args['id'])) {
        $args['sp_id'] = $args['id'];
    }
    if ($args['gl_svc']) {
        if (isset($args['sp_id'])) {
            $args['sp_id'] = COM_applyBasicFilter($args['sp_id']);
        }
        if (isset($args['mode'])) {
            $args['mode'] = COM_applyBasicFilter($args['mode']);
        }
        if (empty($args['sp_id'])) {
            $svc_msg['gl_feed'] = true;
        } else {
            $svc_msg['gl_feed'] = false;
        }
    } else {
        $svc_msg['gl_feed'] = false;
    }
    if (!$svc_msg['gl_feed']) {
        $page = '';
        if (isset($args['sp_id'])) {
            $page = $args['sp_id'];
        }
        $mode = '';
        if (isset($args['mode'])) {
            $mode = $args['mode'];
        }
        $error = 0;
        if ($page == '') {
            $error = 1;
        }
        $perms = SP_getPerms();
        if (!SEC_hasRights('staticpages.edit')) {
            if (!empty($perms)) {
                $perms .= ' AND';
            }
            $perms .= '(draft_flag = 0)';
        }
        if (!empty($perms)) {
            $perms = ' AND ' . $perms;
        }
        $sql = array();
        $sql['mysql'] = "SELECT sp_title,sp_page_title,sp_content,sp_hits,created,modified,sp_format," . "commentcode,meta_description,meta_keywords,template_flag,template_id,draft_flag," . "owner_id,group_id,perm_owner,perm_group," . "perm_members,perm_anon,sp_tid,sp_help,sp_php," . "sp_inblock FROM {$_TABLES['staticpage']} " . "WHERE (sp_id = '{$page}')" . $perms;
        $sql['mssql'] = "SELECT sp_title,sp_page_title," . "CAST(sp_content AS text) AS sp_content,sp_hits," . "created,modified,sp_format,commentcode," . "CAST(meta_description AS text) AS meta_description," . "CAST(meta_keywords AS text) AS meta_keywords,template_flag,template_id,draft_flag," . "owner_id,group_id,perm_owner,perm_group,perm_members," . "perm_anon,sp_tid,sp_help,sp_php,sp_inblock " . "FROM {$_TABLES['staticpage']} WHERE (sp_id = '{$page}')" . $perms;
        $sql['pgsql'] = "SELECT sp_title,sp_page_title,sp_content,sp_hits," . "created,modified,sp_format," . "commentcode,meta_description,meta_keywords,template_flag,template_id,draft_flag," . "owner_id,group_id,perm_owner,perm_group," . "perm_members,perm_anon,sp_tid,sp_help,sp_php," . "sp_inblock FROM {$_TABLES['staticpage']} " . "WHERE (sp_id = '{$page}')" . $perms;
        $result = DB_query($sql);
        $count = DB_numRows($result);
        if ($count == 0 || $count > 1) {
            $error = 1;
        }
        if (!$error) {
            $output = DB_fetchArray($result, false);
            // WE ASSUME $output doesn't have any confidential fields
            if ($output['template_id'] != '') {
                $retval = '';
                $mode = '';
                $xmlObject = simplexml_load_string($output['sp_content']);
                // create array of XML data
                $tag = array();
                foreach ($xmlObject->variable as $variable) {
                    $key = $variable["name"] . '';
                    $value = $variable->data;
                    $tag[$key] = $value;
                }
                // Loop through variables to replace any autotags first
                foreach ($tag as &$value) {
                    $value = PLG_replaceTags($value);
                }
                $args = array('sp_id' => $output['template_id'], 'mode' => $mode, 'gl_svc' => '');
                $svc_msg = array();
                if (PLG_invokeService('staticpages', 'get', $args, $retval, $svc_msg) == PLG_RET_OK) {
                    $retval['sp_content'] = str_replace(array_keys($tag), array_values($tag), $retval['sp_content']);
                    $output['sp_content'] = $retval['sp_content'];
                }
            }
        } else {
            // an error occured (page not found, access denied, ...)
            /**
             * if the user has edit permissions and the page does not exist,
             * send them to the editor so they can create it "wiki style"
             */
            $create_page = false;
            if ($mode !== 'autotag' && $count == 0 && SEC_hasRights('staticpages.edit')) {
                // check again without permissions
                if (DB_count($_TABLES['staticpage'], 'sp_id', $page) == 0) {
                    $url = $_CONF['site_admin_url'] . '/plugins/staticpages/index.php?mode=edit&sp_new_id=' . $page . '&msg=21';
                    $output = COM_refresh($url);
                    $create_page = true;
                }
            }
            if (!$create_page) {
                if (empty($page)) {
                    $failflg = 0;
                } else {
                    $failflg = DB_getItem($_TABLES['staticpage'], 'sp_nf', "sp_id = '{$page}'");
                }
                if ($failflg) {
                    if ($mode !== 'autotag') {
                        $output = COM_siteHeader('menu');
                    }
                    $output .= SEC_loginRequiredForm();
                    if ($mode !== 'autotag') {
                        $output .= COM_siteFooter(true);
                    }
                } else {
                    if ($mode !== 'autotag') {
                        $output = COM_siteHeader('menu');
                    }
                    $output .= COM_startBlock($LANG_ACCESS['accessdenied'], '', COM_getBlockTemplate('_msg_block', 'header'));
                    $output .= $LANG_STATIC['deny_msg'];
                    $output .= COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer'));
                    if ($mode !== 'autotag') {
                        $output .= COM_siteFooter(true);
                    }
                }
            }
            return PLG_RET_ERROR;
        }
        if ($args['gl_svc']) {
            // This date format is PHP 5 only,
            // but only the web-service uses the value
            $output['published'] = date('c', strtotime($output['created']));
            $output['updated'] = date('c', strtotime($output['modified']));
            $output['id'] = $page;
            $output['title'] = $output['sp_title'];
            $output['page_title'] = $output['sp_page_title'];
            $output['category'] = array($output['sp_tid']);
            $output['content'] = $output['sp_content'];
            $output['content_type'] = 'html';
            $owner_data = SESS_getUserDataFromId($output['owner_id']);
            $output['author_name'] = $owner_data['username'];
            $output['link_edit'] = $page;
        }
    } else {
        $output = array();
        $mode = '';
        if (isset($args['mode'])) {
            $mode = $args['mode'];
        }
        $perms = SP_getPerms();
        if (!empty($perms)) {
            $perms = ' WHERE ' . $perms;
        }
        $offset = 0;
        if (isset($args['offset'])) {
            $offset = COM_applyBasicFilter($args['offset'], true);
        }
        $max_items = $_SP_CONF['atom_max_items'] + 1;
        $limit = " LIMIT {$offset}, {$max_items}";
        $order = " ORDER BY modified DESC";
        $sql = array();
        $sql['mysql'] = "SELECT sp_id,sp_title,sp_page_title,sp_content,sp_hits,created,modified,sp_format,meta_description,meta_keywords,template_flag,template_id,draft_flag,owner_id," . "group_id,perm_owner,perm_group,perm_members,perm_anon,sp_tid,sp_help,sp_php," . "sp_inblock FROM {$_TABLES['staticpage']}" . $perms . $order . $limit;
        $sql['mssql'] = "SELECT sp_id,sp_title,sp_page_title,CAST(sp_content AS text) AS sp_content,sp_hits," . "created,modified,sp_format,CAST(meta_description AS text) AS meta_description,CAST(meta_keywords AS text) AS meta_keywords,template_flag,template_id,draft_flag,owner_id,group_id,perm_owner,perm_group,perm_members," . "perm_anon,sp_tid,sp_help,sp_php,sp_inblock FROM {$_TABLES['staticpage']}" . $perms . $order . $limit;
        $sql['pgsql'] = "SELECT sp_id,sp_title,sp_page_title,sp_content,sp_hits,created,modified,sp_format,meta_description,meta_keywords,template_flag,template_id,draft_flag,owner_id," . "group_id,perm_owner,perm_group,perm_members,perm_anon,sp_tid,sp_help,sp_php," . "sp_inblock FROM {$_TABLES['staticpage']}" . $perms . $order . $limit;
        $result = DB_query($sql);
        $count = 0;
        while (($output_item = DB_fetchArray($result, false)) !== false) {
            // WE ASSUME $output doesn't have any confidential fields
            $count += 1;
            if ($count == $max_items) {
                $svc_msg['offset'] = $offset + $_SP_CONF['atom_max_items'];
                break;
            }
            if ($args['gl_svc']) {
                // This date format is PHP 5 only, but only the web-service uses the value
                $output_item['published'] = date('c', strtotime($output_item['created']));
                $output_item['updated'] = date('c', strtotime($output_item['modified']));
                $output_item['id'] = $output_item['sp_id'];
                $output_item['title'] = $output_item['sp_title'];
                $output_item['page_title'] = $output_item['sp_page_title'];
                $output_item['category'] = array($output_item['sp_tid']);
                $output_item['content'] = $output_item['sp_content'];
                $output_item['content_type'] = 'html';
                $owner_data = SESS_getUserDataFromId($output_item['owner_id']);
                $output_item['author_name'] = $owner_data['username'];
            }
            $output[] = $output_item;
        }
    }
    return PLG_RET_OK;
}
Example #6
0
 public function _replaceTags($text)
 {
     return PLG_replaceTags($text, $this->namespace, $this->operation);
 }
Example #7
0
/**
 * Config Option has changed. (use plugin api)
 *
 * @return  void
 */
function plugin_configchange_article($group, $changes = array())
{
    global $_TABLES, $_CONF;
    // If trim length changes then need to redo all related url's for articles
    if ($group == 'Core' && in_array('whats_related_trim', $changes)) {
        $sql = "SELECT sid, introtext, bodytext FROM {$_TABLES['stories']}";
        $result = DB_query($sql);
        $nrows = DB_numRows($result);
        if ($nrows > 0) {
            for ($x = 0; $x < $nrows; $x++) {
                $A = DB_fetchArray($result);
                // Should maybe retrieve through story service but just grab from database and apply any autotags
                // This is all the related story column should really need
                $fulltext = PLG_replaceTags($A['introtext']) . ' ' . PLG_replaceTags($A['bodytext']);
                $related = DB_escapeString(implode("\n", STORY_extractLinks($fulltext, $_CONF['whats_related_trim'])));
                if (!empty($related)) {
                    DB_query("UPDATE {$_TABLES['stories']} SET related = '{$related}' WHERE sid = '{$A['sid']}'");
                }
            }
        }
        // For if any articles are being cached
    } elseif ($group == 'Core' && (in_array('site_name', $changes) || in_array('contributedbyline', $changes) || in_array('allow_user_photo', $changes) || in_array('article_image_align', $changes) || in_array('related_topics', $changes) || in_array('related_topics_max', $changes) || in_array('allow_page_breaks', $changes) || in_array('page_break_comments', $changes) || in_array('url_rewrite', $changes) || in_array('url_routing', $changes) || in_array('hideviewscount', $changes) || in_array('hideemailicon', $changes) || in_array('loginrequired', $changes) || in_array('emailstoryloginrequired', $changes) || in_array('hideprintericon', $changes))) {
        // If any Article options changed then delete all article cache
        $cacheInstance = 'article__';
        CACHE_remove_instance($cacheInstance);
    }
}
Example #8
0
/**
* Return information for a story
*
* This is the story equivalent of PLG_getItemInfo. See lib-plugins.php for
* details.
*
* @param    string  $sid        story ID or '*'
* @param    string  $what       comma-separated list of story properties
* @param    int     $uid        user ID or 0 = current user
* @param    array   $options    (reserved for future extensions)
* @return   mixed               string or array of strings with the information
*
*/
function STORY_getItemInfo($sid, $what, $uid = 0, $options = array())
{
    global $_CONF, $_TABLES;
    // parse $what to see what we need to pull from the database
    $properties = explode(',', $what);
    $fields = array();
    foreach ($properties as $p) {
        switch ($p) {
            case 'date-created':
                $fields[] = 'UNIX_TIMESTAMP(date) AS unixdate';
                break;
            case 'description':
                $fields[] = 'introtext';
                $fields[] = 'bodytext';
                break;
            case 'excerpt':
                $fields[] = 'introtext';
                break;
            case 'feed':
                $fields[] = 'tid';
                break;
            case 'id':
                $fields[] = 'sid';
                break;
            case 'title':
                $fields[] = 'title';
                break;
            case 'url':
                // needed for $sid == '*', but also in case we're only requesting
                // the URL (so that $fields isn't emtpy)
                $fields[] = 'sid';
                break;
            default:
                // nothing to do
                break;
        }
    }
    $fields = array_unique($fields);
    if (count($fields) == 0) {
        $retval = array();
        return $retval;
    }
    // prepare SQL request
    if ($sid == '*') {
        $where = ' WHERE';
    } else {
        $where = " WHERE (sid = '" . addslashes($sid) . "') AND";
    }
    $where .= ' (draft_flag = 0) AND (date <= NOW())';
    if ($uid > 0) {
        $permSql = COM_getPermSql('AND', $uid) . COM_getTopicSql('AND', $uid);
    } else {
        $permSql = COM_getPermSql('AND') . COM_getTopicSql('AND');
    }
    $sql = "SELECT " . implode(',', $fields) . " FROM {$_TABLES['stories']}" . $where . $permSql;
    if ($sid != '*') {
        $sql .= ' LIMIT 1';
    }
    $result = DB_query($sql);
    $numRows = DB_numRows($result);
    $retval = array();
    for ($i = 0; $i < $numRows; $i++) {
        $A = DB_fetchArray($result);
        $props = array();
        foreach ($properties as $p) {
            switch ($p) {
                case 'date-created':
                    $props['date-created'] = $A['unixdate'];
                    break;
                case 'description':
                    $props['description'] = trim(PLG_replaceTags(stripslashes($A['introtext']) . ' ' . stripslashes($A['bodytext'])));
                    break;
                case 'excerpt':
                    $excerpt = stripslashes($A['introtext']);
                    if (!empty($A['bodytext'])) {
                        $excerpt .= "\n\n" . stripslashes($A['bodytext']);
                    }
                    $props['excerpt'] = trim(PLG_replaceTags($excerpt));
                    break;
                case 'feed':
                    $feedfile = DB_getItem($_TABLES['syndication'], 'filename', "topic = '::all'");
                    if (empty($feedfile)) {
                        $feedfile = DB_getItem($_TABLES['syndication'], 'filename', "topic = '::frontpage'");
                    }
                    if (empty($feedfile)) {
                        $feedfile = DB_getItem($_TABLES['syndication'], 'filename', "topic = '{$A['tid']}'");
                    }
                    if (empty($feedfile)) {
                        $props['feed'] = '';
                    } else {
                        $props['feed'] = SYND_getFeedUrl($feedfile);
                    }
                    break;
                case 'id':
                    $props['id'] = $A['sid'];
                    break;
                case 'title':
                    $props['title'] = stripslashes($A['title']);
                    break;
                case 'url':
                    if (empty($A['sid'])) {
                        $props['url'] = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $sid);
                    } else {
                        $props['url'] = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $A['sid']);
                    }
                    break;
                default:
                    // return empty string for unknown properties
                    $props[$p] = '';
                    break;
            }
        }
        $mapped = array();
        foreach ($props as $key => $value) {
            if ($sid == '*') {
                if ($value != '') {
                    $mapped[$key] = $value;
                }
            } else {
                $mapped[] = $value;
            }
        }
        if ($sid == '*') {
            $retval[] = $mapped;
        } else {
            $retval = $mapped;
            break;
        }
    }
    if ($sid != '*' && count($retval) == 1) {
        $retval = $retval[0];
    }
    return $retval;
}
Example #9
0
 public function parse($p1, $p2 = '', $fulltag)
 {
     global $_CONF, $_TABLES, $_USER, $LANG01;
     USES_lib_comments();
     $retval = '';
     $skip = 0;
     $dt = new Date('now', $_USER['tzid']);
     // topic = specific topic or 'all'
     // display = how many stories to display, if 0, then all
     // meta = show meta data (i.e.; who when etc)
     // titleLink - make title a hot link
     // featured - 0 = show all, 1 = only featured, 2 = all except featured
     // frontpage - 1 = show only items marked for frontpage - 0 = show all
     // cols - number of columns to show
     // template - the template name
     $topic = $p1;
     if ($topic == 'all') {
         $topic = '';
     }
     $uniqueID = md5($p1 . $p2);
     $display = 10;
     // display 10 articles
     $meta = 0;
     // do not display meta data
     $titleLink = 0;
     // do not use links in title
     $featured = 0;
     // 0 = show all, 1 = only featured, 2 = all except featured
     $frontpage = 0;
     // only show items marked for frontpage
     $cols = 3;
     // number of columns
     $truncate = 0;
     // maximum number of characters to include in story text
     $template = 'headlines.thtml';
     $px = explode(' ', trim($p2));
     if (is_array($px)) {
         foreach ($px as $part) {
             if (substr($part, 0, 8) == 'display:') {
                 $a = explode(':', $part);
                 $display = $a[1];
                 $skip++;
             } elseif (substr($part, 0, 5) == 'meta:') {
                 $a = explode(':', $part);
                 $meta = $a[1];
                 $skip++;
             } elseif (substr($part, 0, 10) == 'titlelink:') {
                 $a = explode(':', $part);
                 $titleLink = $a[1];
                 $skip++;
             } elseif (substr($part, 0, 9) == 'featured:') {
                 $a = explode(':', $part);
                 $featured = $a[1];
                 $skip++;
             } elseif (substr($part, 0, 10) == 'frontpage:') {
                 $a = explode(':', $part);
                 $frontpage = (int) $a[1];
                 $skip++;
             } elseif (substr($part, 0, 5) == 'cols:') {
                 $a = explode(':', $part);
                 $cols = $a[1];
                 $skip++;
             } elseif (substr($part, 0, 9) == 'template:') {
                 $a = explode(':', $part);
                 $template = $a[1];
                 $skip++;
             } elseif (substr($part, 0, 9) == 'truncate:') {
                 $a = explode(':', $part);
                 $truncate = (int) $a[1];
                 $skip++;
             } else {
                 break;
             }
         }
         if ($skip != 0) {
             if (count($px) > $skip) {
                 for ($i = 0; $i < $skip; $i++) {
                     array_shift($px);
                 }
                 $caption = trim(implode(' ', $px));
             } else {
                 $caption = '';
             }
         }
     } else {
         $caption = trim($p2);
     }
     if ($display < 0) {
         $display = 3;
     }
     $hash = CACHE_security_hash();
     $instance_id = 'whatsnew_headlines_' . $uniqueID . '_' . $hash . '_' . $_USER['theme'];
     if (($cache = CACHE_check_instance($instance_id, 0)) !== FALSE) {
         return $cache;
     }
     $archivetid = DB_getItem($_TABLES['topics'], 'tid', "archive_flag=1");
     $sql = " (date <= NOW()) AND (draft_flag = 0)";
     if (empty($topic)) {
         $sql .= COM_getLangSQL('tid', 'AND', 's');
     }
     // if a topic was provided only select those stories.
     if (!empty($topic)) {
         $sql .= " AND s.tid = '" . DB_escapeString($topic) . "' ";
     }
     if ($featured == 1) {
         $sql .= " AND s.featured = 1 ";
     } else {
         if ($featured == 2) {
             $sql .= " AND s.featured = 0 ";
         }
     }
     if ($frontpage == 1) {
         $sql .= " AND frontpage = 1 ";
     }
     if ($topic != $archivetid) {
         $sql .= " AND s.tid != '{$archivetid}' ";
     }
     $sql .= COM_getPermSQL('AND', 0, 2, 's');
     $sql .= COM_getTopicSQL('AND', 0, 's') . ' ';
     $userfields = 'u.uid, u.username, u.fullname';
     if ($_CONF['allow_user_photo'] == 1) {
         $userfields .= ', u.photo';
         if ($_CONF['use_gravatar']) {
             $userfields .= ', u.email';
         }
     }
     $orderBy = ' date DESC ';
     $headlinesSQL = "SELECT STRAIGHT_JOIN s.*, UNIX_TIMESTAMP(s.date) AS unixdate, " . 'UNIX_TIMESTAMP(s.expire) as expireunix, ' . $userfields . ", t.topic, t.imageurl " . "FROM {$_TABLES['stories']} AS s, {$_TABLES['users']} AS u, " . "{$_TABLES['topics']} AS t WHERE (s.uid = u.uid) AND (s.tid = t.tid) AND" . $sql . "ORDER BY featured DESC," . $orderBy;
     if ($display > 0) {
         $headlinesSQL .= " LIMIT " . $display;
     }
     $result = DB_query($headlinesSQL);
     $numRows = DB_numRows($result);
     if ($numRows < $cols) {
         $cols = $numRows;
     }
     if ($cols > 6) {
         $cols = 6;
     }
     if ($numRows > 0) {
         $T = new Template($_CONF['path'] . 'system/autotags/');
         $T->set_file('page', $template);
         $T->set_var('columns', $cols);
         $T->set_block('page', 'headlines', 'hl');
         $newstories = array();
         while ($A = DB_fetchArray($result)) {
             $T->unset_var('readmore_url');
             $T->unset_var('lang_readmore');
             if ($A['attribution_author'] != '') {
                 $author = $A['attribution_author'];
             } else {
                 $author = $A['username'];
             }
             $title = COM_undoSpecialChars($A['title']);
             $title = str_replace('&nbsp;', ' ', $title);
             $subtitle = COM_undoSpecialChars($A['subtitle']);
             if ($A['story_image'] != '') {
                 $story_image = $_CONF['site_url'] . $A['story_image'];
             } else {
                 $story_image = '';
             }
             $A['introtext'] = STORY_renderImages($A['sid'], $A['introtext']);
             if (!empty($A['bodytext'])) {
                 $closingP = strrpos($A['introtext'], "</p>");
                 if ($closingP !== FALSE) {
                     $text = substr($A['introtext'], 0, $closingP);
                     $A['introtext'] = $text;
                 }
                 // adds the read more link
                 $T->set_var('readmore_url', COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $A['sid']));
                 $T->set_var('lang_readmore', $LANG01['continue_reading']);
             }
             if ($truncate > 0) {
                 $A['introtext'] = $this->truncateHTML($A['introtext'], $truncate, '...');
             }
             $topicurl = $_CONF['site_url'] . '/index.php?topic=' . $A['tid'];
             $dt->setTimestamp($A['unixdate']);
             if ($A['commentcode'] >= 0) {
                 $cmtLinkArray = CMT_getCommentLinkWithCount('article', $A['sid'], $_CONF['site_url'] . '/article.php?story=' . $A['sid'], $A['comments'], 1);
                 $T->set_var(array('lang_comments' => '', 'comments_count' => $cmtLinkArray['comment_count'], 'comments_url' => $cmtLinkArray['url'], 'comments_url_extra' => $cmtLinkArray['url_extra']));
             } else {
                 $T->unset_var('lang_comments');
                 $T->unset_var('comments_count');
                 $T->unset_var('comments_url');
                 $T->unset_var('comments_url_extra');
             }
             $T->set_var(array('titlelink' => $titleLink ? TRUE : '', 'meta' => $meta ? TRUE : '', 'lang_by' => $LANG01[95], 'lang_posted_in' => $LANG01['posted_in'], 'story_topic_url' => $topicurl, 'title' => $title, 'subtitle' => $subtitle, 'story_image' => $story_image, 'text' => PLG_replaceTags($A['introtext']), 'date' => $A['date'], 'time' => $dt->format('Y-m-d', true) . 'T' . $dt->format('H:i:s', true), 'topic' => $A['topic'], 'tid' => $A['tid'], 'author' => $author, 'author_id' => $A['uid'], 'sid' => $A['sid'], 'short_date' => $dt->format($_CONF['shortdate'], true), 'date_only' => $dt->format($_CONF['dateonly'], true), 'date' => $dt->format($dt->getUserFormat(), true), 'url' => COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $A['sid']), 'attribution_url' => $A['attribution_url'], 'attribution_name' => $A['attribution_name']));
             $T->parse('hl', 'headlines', true);
         }
         $retval = $T->finish($T->parse('output', 'page'));
         CACHE_create_instance($instance_id, $retval, 0);
     }
     return $retval;
 }
Example #10
0
/**
* This function prints &$comments (db results set of comments) in comment format
* -For previews, &$comments is assumed to be an associative array containing
*  data for a single comment.
*
* @param    array    &$comments Database result set of comments to be printed
* @param    string   $mode      'flat', 'threaded', etc
* @param    string   $type      Type of item (article, poll, etc.)
* @param    string   $order     How to order the comments 'ASC' or 'DESC'
* @param    boolean  $delete_option   if current user can delete comments
* @param    boolean  $preview   Preview display (for edit) or not
* @param    int      $ccode     Comment code: -1=no comments, 0=allowed, 1=closed
* @return   string   HTML       Formated Comment
*
*/
function CMT_getComment(&$comments, $mode, $type, $order, $delete_option = false, $preview = false, $ccode = 0)
{
    global $_CONF, $_TABLES, $_USER, $LANG01, $LANG03, $MESSAGE, $_IMAGE_TYPE;
    $indent = 0;
    // begin with 0 indent
    $retval = '';
    // initialize return value
    $template = new Template($_CONF['path_layout'] . 'comment');
    $template->set_file(array('comment' => 'comment.thtml', 'thread' => 'thread.thtml'));
    // generic template variables
    $template->set_var('xhtml', XHTML);
    $template->set_var('site_url', $_CONF['site_url']);
    $template->set_var('site_admin_url', $_CONF['site_admin_url']);
    $template->set_var('layout_url', $_CONF['layout_url']);
    $template->set_var('lang_authoredby', $LANG01[42]);
    $template->set_var('lang_on', $LANG01[36]);
    $template->set_var('lang_permlink', $LANG01[120]);
    $template->set_var('order', $order);
    if ($ccode == 0) {
        $template->set_var('lang_replytothis', $LANG01[43]);
        $template->set_var('lang_reply', $LANG01[25]);
    } else {
        $template->set_var('lang_replytothis', '');
        $template->set_var('lang_reply', '');
    }
    // Make sure we have a default value for comment indentation
    if (!isset($_CONF['comment_indent'])) {
        $_CONF['comment_indent'] = 25;
    }
    if ($preview) {
        $A = $comments;
        if (empty($A['nice_date'])) {
            $A['nice_date'] = time();
        }
        if (!isset($A['cid'])) {
            $A['cid'] = 0;
        }
        if (!isset($A['photo'])) {
            if (isset($_USER['photo'])) {
                $A['photo'] = $_USER['photo'];
            } else {
                $A['photo'] = '';
            }
        }
        if (!isset($A['email'])) {
            if (isset($_USER['email'])) {
                $A['email'] = $_USER['email'];
            } else {
                $A['email'] = '';
            }
        }
        $mode = 'flat';
    } else {
        $A = DB_fetchArray($comments);
    }
    if (empty($A)) {
        return '';
    }
    $token = '';
    if ($delete_option && !$preview) {
        $token = SEC_createToken();
    }
    // check for comment edit
    $row = 1;
    do {
        // check for comment edit
        $commentedit = DB_query("SELECT cid,uid,UNIX_TIMESTAMP(time) AS time FROM {$_TABLES['commentedits']} WHERE cid = {$A['cid']}");
        $B = DB_fetchArray($commentedit);
        if ($B) {
            //comment edit present
            // get correct editor name
            if ($A['uid'] == $B['uid']) {
                $editname = $A['username'];
            } else {
                $editname = DB_getItem($_TABLES['users'], 'username', "uid={$B['uid']}");
            }
            // add edit info to text
            $A['comment'] .= '<div class="comment-edit">' . $LANG03[30] . ' ' . strftime($_CONF['date'], $B['time']) . ' ' . $LANG03[31] . ' ' . $editname . '</div><!-- /COMMENTEDIT -->';
        }
        // determines indentation for current comment
        if ($mode == 'threaded' || $mode == 'nested') {
            $indent = ($A['indent'] - $A['pindent']) * $_CONF['comment_indent'];
        }
        // comment variables
        $template->set_var('indent', $indent);
        $template->set_var('author_name', strip_tags($A['username']));
        $template->set_var('author_id', $A['uid']);
        $template->set_var('cid', $A['cid']);
        $template->set_var('cssid', $row % 2);
        if ($A['uid'] > 1) {
            $fullname = '';
            if (!empty($A['fullname'])) {
                $fullname = $A['fullname'];
            }
            $fullname = COM_getDisplayName($A['uid'], $A['username'], $fullname);
            $template->set_var('author_fullname', $fullname);
            $template->set_var('author', $fullname);
            $alttext = $fullname;
            $photo = '';
            if ($_CONF['allow_user_photo']) {
                if (isset($A['photo']) && empty($A['photo'])) {
                    $A['photo'] = '(none)';
                }
                $photo = USER_getPhoto($A['uid'], $A['photo'], $A['email']);
            }
            if (!empty($photo)) {
                $template->set_var('author_photo', $photo);
                $camera_icon = '<img src="' . $_CONF['layout_url'] . '/images/smallcamera.' . $_IMAGE_TYPE . '" alt=""' . XHTML . '>';
                $template->set_var('camera_icon', COM_createLink($camera_icon, $_CONF['site_url'] . '/users.php?mode=profile&amp;uid=' . $A['uid']));
            } else {
                $template->set_var('author_photo', '');
                $template->set_var('camera_icon', '');
            }
            $template->set_var('start_author_anchortag', '<a href="' . $_CONF['site_url'] . '/users.php?mode=profile&amp;uid=' . $A['uid'] . '">');
            $template->set_var('end_author_anchortag', '</a>');
            $template->set_var('author_link', COM_createLink($fullname, $_CONF['site_url'] . '/users.php?mode=profile&amp;uid=' . $A['uid']));
        } else {
            //comment is from anonymous user
            if (isset($A['name'])) {
                $A['username'] = strip_tags($A['name']);
            }
            $template->set_var('author', $A['username']);
            $template->set_var('author_fullname', $A['username']);
            $template->set_var('author_link', $A['username']);
            $template->set_var('author_photo', '');
            $template->set_var('camera_icon', '');
            $template->set_var('start_author_anchortag', '');
            $template->set_var('end_author_anchortag', '');
        }
        // hide reply link from anonymous users if they can't post replies
        $hidefromanon = false;
        if (empty($_USER['username']) && ($_CONF['loginrequired'] == 1 || $_CONF['commentsloginrequired'] == 1)) {
            $hidefromanon = true;
        }
        // this will hide HTML that should not be viewed in preview mode
        if ($preview || $hidefromanon) {
            $template->set_var('hide_if_preview', 'style="display:none"');
        } else {
            $template->set_var('hide_if_preview', '');
        }
        // for threaded mode, add a link to comment parent
        if ($mode == 'threaded' && $A['pid'] != 0 && $indent == 0) {
            $result = DB_query("SELECT title,pid FROM {$_TABLES['comments']} WHERE cid = '{$A['pid']}'");
            $P = DB_fetchArray($result);
            if ($P['pid'] != 0) {
                $plink = $_CONF['site_url'] . '/comment.php?mode=display&amp;sid=' . $A['sid'] . '&amp;title=' . urlencode(htmlspecialchars($P['title'])) . '&amp;type=' . $type . '&amp;order=' . $order . '&amp;pid=' . $P['pid'] . '&amp;format=threaded';
            } else {
                $plink = $_CONF['site_url'] . '/comment.php?mode=view&amp;sid=' . $A['sid'] . '&amp;title=' . urlencode(htmlspecialchars($P['title'])) . '&amp;type=' . $type . '&amp;order=' . $order . '&amp;cid=' . $A['pid'] . '&amp;format=threaded';
            }
            $parent_link = COM_createLink($LANG01[44], $plink) . ' | ';
            $template->set_var('parent_link', $parent_link);
        } else {
            $template->set_var('parent_link', '');
        }
        $template->set_var('date', strftime($_CONF['date'], $A['nice_date']));
        $template->set_var('sid', $A['sid']);
        $template->set_var('type', $A['type']);
        // COMMENT edit rights
        $edit_option = false;
        if (isset($A['uid']) && isset($_USER['uid']) && $_USER['uid'] == $A['uid'] && $_CONF['comment_edit'] == 1 && time() - $A['nice_date'] < $_CONF['comment_edittime'] && DB_getItem($_TABLES['comments'], 'COUNT(*)', "pid = {$A['cid']}") == 0) {
            $edit_option = true;
            if (empty($token)) {
                $token = SEC_createToken();
            }
        } elseif (SEC_hasRights('comment.moderate')) {
            $edit_option = true;
        }
        // edit link
        $edit = '';
        if ($edit_option) {
            $editlink = $_CONF['site_url'] . '/comment.php?mode=edit&amp;cid=' . $A['cid'] . '&amp;sid=' . $A['sid'] . '&amp;type=' . $type;
            $edit = COM_createLink($LANG01[4], $editlink) . ' | ';
        }
        // unsubscribe link
        $unsubscribe = '';
        if ($_CONF['allow_reply_notifications'] == 1 && !COM_isAnonUser() && isset($A['uid']) && isset($_USER['uid']) && $_USER['uid'] == $A['uid']) {
            $hash = DB_getItem($_TABLES['commentnotifications'], 'deletehash', "cid = {$A['cid']} AND uid = {$_USER['uid']}");
            if (!empty($hash)) {
                $unsublink = $_CONF['site_url'] . '/comment.php?mode=unsubscribe&amp;key=' . $hash;
                $unsubattr = array('title' => $LANG03[43]);
                $unsubscribe = COM_createLink($LANG03[42], $unsublink, $unsubattr) . ' | ';
            }
        }
        // if deletion is allowed, displays delete link
        if ($delete_option) {
            $deloption = '';
            // always place edit option first, if available
            if (!empty($edit)) {
                $deloption .= $edit;
            }
            // actual delete option
            $dellink = $_CONF['site_url'] . '/comment.php?mode=delete&amp;cid=' . $A['cid'] . '&amp;sid=' . $A['sid'] . '&amp;type=' . $type . '&amp;' . CSRF_TOKEN . '=' . $token;
            $delattr = array('onclick' => "return confirm('{$MESSAGE[76]}');");
            $deloption .= COM_createLink($LANG01[28], $dellink, $delattr) . ' | ';
            if (!empty($A['ipaddress'])) {
                if (empty($_CONF['ip_lookup'])) {
                    $deloption .= $A['ipaddress'] . '  | ';
                } else {
                    $iplookup = str_replace('*', $A['ipaddress'], $_CONF['ip_lookup']);
                    $deloption .= COM_createLink($A['ipaddress'], $iplookup) . ' | ';
                }
            }
            if (!empty($unsubscribe)) {
                $deloption .= $unsubscribe;
            }
            $template->set_var('delete_option', $deloption);
        } elseif ($edit_option) {
            $template->set_var('delete_option', $edit . $unsubscribe);
        } elseif (!COM_isAnonUser()) {
            $reportthis = '';
            if ($A['uid'] != $_USER['uid']) {
                $reportthis_link = $_CONF['site_url'] . '/comment.php?mode=report&amp;cid=' . $A['cid'] . '&amp;type=' . $type;
                $report_attr = array('title' => $LANG01[110]);
                $reportthis = COM_createLink($LANG01[109], $reportthis_link, $report_attr) . ' | ';
            }
            $template->set_var('delete_option', $reportthis . $unsubscribe);
        } else {
            $template->set_var('delete_option', '');
        }
        //and finally: format the actual text of the comment, but check only the text, not sig or edit
        $text = str_replace('<!-- COMMENTSIG --><div class="comment-sig">', '', $A['comment']);
        $text = str_replace('</div><!-- /COMMENTSIG -->', '', $text);
        $text = str_replace('<div class="comment-edit">', '', $text);
        $text = str_replace('</div><!-- /COMMENTEDIT -->', '', $text);
        if (preg_match('/<.*>/', $text) == 0) {
            $A['comment'] = nl2br($A['comment']);
        }
        // highlight search terms if specified
        if (!empty($_REQUEST['query'])) {
            $A['comment'] = COM_highlightQuery($A['comment'], $_REQUEST['query']);
        }
        $A['comment'] = str_replace('$', '&#36;', $A['comment']);
        $A['comment'] = str_replace('{', '&#123;', $A['comment']);
        $A['comment'] = str_replace('}', '&#125;', $A['comment']);
        // Replace any plugin autolink tags
        $A['comment'] = PLG_replaceTags($A['comment']);
        // create a reply to link
        $reply_link = '';
        if ($ccode == 0) {
            $reply_link = $_CONF['site_url'] . '/comment.php?sid=' . $A['sid'] . '&amp;pid=' . $A['cid'] . '&amp;title=' . urlencode($A['title']) . '&amp;type=' . $A['type'];
            $reply_option = COM_createLink($LANG01[43], $reply_link, array('rel' => 'nofollow')) . ' | ';
            $template->set_var('reply_option', $reply_option);
        } else {
            $template->set_var('reply_option', '');
        }
        $template->set_var('reply_link', $reply_link);
        // format title for display, must happen after reply_link is created
        $A['title'] = htmlspecialchars($A['title']);
        $A['title'] = str_replace('$', '&#36;', $A['title']);
        $template->set_var('title', $A['title']);
        $template->set_var('comments', $A['comment']);
        // parse the templates
        if ($mode == 'threaded' && $indent > 0) {
            $template->set_var('pid', $A['pid']);
            $retval .= $template->parse('output', 'thread');
        } else {
            $template->set_var('pid', $A['cid']);
            $retval .= $template->parse('output', 'comment');
        }
        $row++;
    } while ($A = DB_fetchArray($comments));
    return $retval;
}
Example #11
0
/**
*   Create a list of events
*
*   @param  integer $range          Range indicator (upcoming, past, etc)
*   @param  integer $category       Category to limit search
*   @param  string  $block_title    Title of block
*   @return string      HTML for list page
*/
function EVLIST_listview($range = '', $category = '', $calendar = '', $block_title = '')
{
    global $_CONF, $_EV_CONF, $_USER, $_TABLES, $LANG_EVLIST;
    EVLIST_setViewSession('list', $year, $month, $day);
    $retval = '';
    $T = new Template(EVLIST_PI_PATH . '/templates/');
    $T->set_file('index', 'index.thtml');
    if ($_EV_CONF['_can_add']) {
        $add_event_link = EVLIST_URL . '/event.php?edit=x';
    } else {
        $add_event_link = '';
    }
    $T->set_var(array('action' => EVLIST_URL . '/index.php', 'range_options' => EVLIST_GetOptions($LANG_EVLIST['ranges'], $range), 'add_event_link' => $add_event_link, 'add_event_text' => $LANG_EVLIST['add_event'], 'rangetext' => $LANG_EVLIST['ranges'][$range]));
    $page = empty($_GET['page']) ? 1 : (int) $_GET['page'];
    $opts = array('cat' => $category, 'page' => $page, 'limit' => $_EV_CONF['limit_list'], 'cal' => $calendar);
    switch ($range) {
        case 1:
            // past
            $start = EV_MIN_DATE;
            $end = $_EV_CONF['_today'];
            $opts['order'] = 'DESC';
            break;
        case 3:
            //this week
            $start = $_EV_CONF['_today'];
            $end = date('Y-m-d', strtotime('+1 week', $_EV_CONF['_today_ts']));
            break;
        case 4:
            //this month
            $start = $_EV_CONF['_today'];
            $end = date('Y-m-d', strtotime('+1 month', $_EV_CONF['_today_ts']));
            break;
        case 2:
            //upcoming
        //upcoming
        default:
            $start = $_EV_CONF['_today'];
            $end = EV_MAX_DATE;
            break;
    }
    $events = EVLIST_getEvents($start, $end, $opts);
    if (empty($events)) {
        //return empty list msg
        $T->set_var(array('title' => '', 'block_title' => $block_title, 'empty_listmsg' => $LANG_EVLIST['no_match']));
        if (!empty($range)) {
            $andrange = '&amp;range=' . $range;
            $T->set_var('range', $range);
        } else {
            $andrange = '&amp;range=2';
        }
        if (!empty($category)) {
            $andcat = '&amp;cat=' . $category;
            $T->set_var('category', $category);
        } else {
            $andcat = '';
        }
    } else {
        //populate list
        // So we don't call SEC_hasRights inside the loop
        $isAdmin = SEC_hasRights('evlist.admin');
        $T->set_file(array('item' => 'list_item.thtml', 'editlinks' => 'edit_links.thtml', 'category_form' => 'category_dd.thtml'));
        if (!empty($range)) {
            $andrange = '&amp;range=' . $range;
            $T->set_var('range', $range);
        } else {
            $andrange = '&amp;range=2';
        }
        if (!empty($category)) {
            $andcat = '&amp;cat=' . $category;
            $T->set_var('category', $category);
        } else {
            $andcat = '';
        }
        // Track events that have been shown so we show them only once.
        $already_shown = array();
        foreach ($events as $date => $daydata) {
            foreach ($daydata as $A) {
                if (array_key_exists($A['rp_id'], $already_shown)) {
                    continue;
                } else {
                    $already_shown[$A['rp_id']] = 1;
                }
                $titlelink = COM_buildURL(EVLIST_URL . '/event.php?eid=' . $A['rp_id'] . $timestamp . $andrange . $andcat);
                $titlelink = '<a href="' . $titlelink . '">' . COM_stripslashes($A['title']) . '</a>';
                $summary = PLG_replaceTags(COM_stripslashes($A['summary']));
                $datesummary = sprintf($LANG_EVLIST['event_begins'], EVLIST_formattedDate(strtotime($A['rp_date_start'])));
                $morelink = COM_buildURL(EVLIST_URL . '/event.php?eid=' . $A['rp_id'] . $timestamp . $andrange . $andcat);
                $morelink = '<a href="' . $morelink . '">' . $LANG_EVLIST['read_more'] . '</a>';
                if (empty($A['email'])) {
                    $contactlink = $_CONF['site_url'] . '/profiles.php?uid=' . $A['owner_id'];
                } else {
                    $contactlink = 'mailto:' . EVLIST_obfuscate($A['email']);
                }
                $contactlink = '<a href="' . $contactlink . '">' . $LANG_EVLIST['ev_contact'] . '</a>';
                $T->set_var(array('title' => $titlelink, 'date_summary' => $datesummary, 'summary' => $summary, 'more_link' => $morelink, 'contact_link' => $contactlink, 'contact_name' => $A['contact'], 'owner_name' => COM_getDisplayName($A['owner_id']), 'block_title' => $block_title, 'category_links' => EVLIST_getCatLinks($A['ev_id'], $andrange), 'cal_id' => $A['cal_id'], 'cal_name' => $A['cal_name'], 'cal_fgcolor' => $A['fgcolor'], 'cal_bgcolor' => $A['bgcolor']));
                $T->parse('event_item', 'item', true);
            }
        }
    }
    $T->parse('output', 'index');
    $retval .= $T->finish($T->get_var('output'));
    // Set page navigation
    $retval .= EVLIST_pagenav($start, $end, $category, $page, $range, $calendar);
    return $retval;
}
Example #12
0
/**
* Saves link to the database
*
* @param    string  $lid            ID for link
* @param    string  $old_lid        old ID for link
* @param    string  $cid            cid of category link belongs to
* @param    string  $categorydd     Category links belong to
* @param    string  $url            URL of link to save
* @param    string  $description    Description of link
* @param    string  $title          Title of link
* @param    int     $hits           Number of hits for link
* @param    int     $owner_id       ID of owner
* @param    int     $group_id       ID of group link belongs to
* @param    int     $perm_owner     Permissions the owner has
* @param    int     $perm_group     Permissions the group has
* @param    int     $perm_members   Permissions members have
* @param    int     $perm_anon      Permissions anonymous users have
* @return   string                  HTML redirect or error message
* @global array core config vars
* @global array core group data
* @global array core table data
* @global array core user data
* @global array core msg data
* @global array links plugin lang admin vars
*
*/
function savelink($lid, $old_lid, $cid, $categorydd, $url, $description, $title, $hits, $owner_id, $group_id, $perm_owner, $perm_group, $perm_members, $perm_anon)
{
    global $_CONF, $_GROUPS, $_TABLES, $_USER, $MESSAGE, $LANG_LINKS_ADMIN, $_LI_CONF;
    $retval = '';
    // Convert array values to numeric permission values
    if (is_array($perm_owner) or is_array($perm_group) or is_array($perm_members) or is_array($perm_anon)) {
        list($perm_owner, $perm_group, $perm_members, $perm_anon) = SEC_getPermissionValues($perm_owner, $perm_group, $perm_members, $perm_anon);
    }
    // Remove any autotags the user doesn't have permission to use
    $description = PLG_replaceTags($description, '', true);
    // clean 'em up
    $description = DB_escapeString(COM_checkHTML(COM_checkWords($description), 'links.edit'));
    $title = DB_escapeString(strip_tags(COM_checkWords($title)));
    $cid = DB_escapeString($cid);
    if (empty($owner_id)) {
        // this is new link from admin, set default values
        $owner_id = $_USER['uid'];
        if (isset($_GROUPS['Links Admin'])) {
            $group_id = $_GROUPS['Links Admin'];
        } else {
            $group_id = SEC_getFeatureGroup('links.edit');
        }
        $perm_owner = 3;
        $perm_group = 2;
        $perm_members = 2;
        $perm_anon = 2;
    }
    $lid = COM_sanitizeID($lid);
    $old_lid = COM_sanitizeID($old_lid);
    if (empty($lid)) {
        if (empty($old_lid)) {
            $lid = COM_makeSid();
        } else {
            $lid = $old_lid;
        }
    }
    // check for link id change
    if (!empty($old_lid) && $lid != $old_lid) {
        // check if new lid is already in use
        if (DB_count($_TABLES['links'], 'lid', $lid) > 0) {
            // TBD: abort, display editor with all content intact again
            $lid = $old_lid;
            // for now ...
        }
    }
    $access = 0;
    $old_lid = DB_escapeString($old_lid);
    if (DB_count($_TABLES['links'], 'lid', $old_lid) > 0) {
        $result = DB_query("SELECT owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon FROM {$_TABLES['links']} WHERE lid = '{$old_lid}'");
        $A = DB_fetchArray($result);
        $access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']);
    } else {
        $access = SEC_hasAccess($owner_id, $group_id, $perm_owner, $perm_group, $perm_members, $perm_anon);
    }
    if ($access < 3 || !SEC_inGroup($group_id)) {
        $display .= COM_showMessageText($MESSAGE[29], $MESSAGE[30]);
        $display = COM_createHTMLDocument($display, array('pagetitle' => $MESSAGE[30]));
        COM_accessLog("User {$_USER['username']} tried to illegally submit or edit link {$lid}.");
        COM_output($display);
        exit;
    } elseif (!empty($title) && !empty($description) && !empty($url)) {
        if ($categorydd != $LANG_LINKS_ADMIN[7] && !empty($categorydd)) {
            $cid = DB_escapeString($categorydd);
        } else {
            if ($categorydd != $LANG_LINKS_ADMIN[7]) {
                echo COM_refresh($_CONF['site_admin_url'] . '/plugins/links/index.php');
            }
        }
        DB_delete($_TABLES['linksubmission'], 'lid', $old_lid);
        DB_delete($_TABLES['links'], 'lid', $old_lid);
        DB_save($_TABLES['links'], 'lid,cid,url,description,title,date,hits,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon', "'{$lid}','{$cid}','{$url}','{$description}','{$title}',NOW(),'{$hits}',{$owner_id},{$group_id},{$perm_owner},{$perm_group},{$perm_members},{$perm_anon}");
        if (empty($old_lid) || $old_lid == $lid) {
            PLG_itemSaved($lid, 'links');
        } else {
            PLG_itemSaved($lid, 'links', $old_lid);
        }
        // Get category for rdf check
        $category = DB_getItem($_TABLES['linkcategories'], "category", "cid='{$cid}'");
        COM_rdfUpToDateCheck('links', $category, $lid);
        return PLG_afterSaveSwitch($_LI_CONF['aftersave'], COM_buildURL("{$_CONF['site_url']}/links/portal.php?what=link&item={$lid}"), 'links', 2);
    } else {
        // missing fields
        $retval .= COM_errorLog($LANG_LINKS_ADMIN[10], 2);
        if (DB_count($_TABLES['links'], 'lid', $old_lid) > 0) {
            $retval .= editlink('edit', $old_lid);
        } else {
            $retval .= editlink('edit', '');
        }
        $retval = COM_createHTMLDocument($retval, array('pagetitle' => $LANG_LINKS_ADMIN[1]));
        return $retval;
    }
}
Example #13
0
 /**
  *   Display the detail page for the product.
  *
  *   @return string      HTML for the product page.
  */
 public function Detail()
 {
     global $_CONF, $_PP_CONF, $_TABLES, $LANG_PP, $_USER, $_SYSTEM;
     USES_lib_comments();
     $prod_id = $this->id;
     if ($prod_id < 1 || !$this->enabled || !$this->isAvailable()) {
         return PAYPAL_errorMessage($LANG_PP['invalid_product_id'], 'info');
     }
     $retval = COM_startBlock();
     // Set the template dir based on the configured template version
     $tpl_dir = PAYPAL_PI_PATH . '/templates/detail/' . $_PP_CONF['product_tpl_ver'];
     $T = new Template($tpl_dir);
     $T->set_file('product', 'product_detail_attrib.thtml');
     $name = $this->name;
     $l_desc = PLG_replaceTags($this->description);
     $s_desc = PLG_replaceTags($this->short_description);
     // Highlight the query terms if coming from a search
     if (isset($_REQUEST['query']) && !empty($_REQUEST['query'])) {
         $name = COM_highlightQuery($name, $_REQUEST['query']);
         $l_desc = COM_highlightQuery($l_desc, $_REQUEST['query']);
         $s_desc = COM_highlightQuery($s_desc, $_REQUEST['query']);
     }
     $onsale = $this->isOnSale();
     $act_price = $onsale ? $this->sale_price : $this->price;
     $qty_disc_txt = '';
     foreach ($this->qty_discounts as $qty => $pct) {
         $qty_disc_txt .= sprintf('Buy %d, save %.02f%%<br />', $qty, $pct);
     }
     // Get custom text input fields
     if ('' != $this->custom) {
         $T->set_block('product', 'CustAttrib', 'cAttr');
         $text_field_names = explode('|', $this->custom);
         foreach ($text_field_names as $id => $text_field_name) {
             $T->set_var(array('fld_id' => "cust_text_fld_{$id}", 'fld_name' => htmlspecialchars($text_field_name)));
             $T->parse('cAttr', 'CustAttrib', true);
         }
     }
     $T->set_var(array('is_uikit' => $_SYSTEM['framework'] == 'uikit' ? 'true' : '', 'have_attributes' => $this->hasAttributes(), 'id' => $prod_id, 'name' => $name, 'short_description' => $s_desc, 'description' => $l_desc, 'cur_decimals' => $this->currency->Decimals(), 'price' => $this->currency->FormatValue($act_price), 'orig_price' => $this->currency->Format($this->price), 'on_sale' => $onsale ? 'true' : '', 'img_cell_width' => $_PP_CONF['max_thumb_size'] + 20, 'price_prefix' => $this->currency->Pre(), 'price_postfix' => $this->currency->Post(), 'onhand' => $this->track_onhand ? $this->onhand : '', 'qty_disc' => $qty_disc_txt));
     // Retrieve the photos and put into the template
     $sql = "SELECT img_id, filename\n                FROM {$_TABLES['paypal.images']} \n                WHERE product_id='{$prod_id}'";
     //echo $sql;die;
     $img_res = DB_query($sql);
     $photo_detail = '';
     $T->set_var('have_photo', '');
     // assume no photo available
     if ($img_res && DB_numRows($img_res) > 0) {
         for ($i = 0; $prow = DB_fetchArray($img_res, false); $i++) {
             if ($prow['filename'] != '' && file_exists("{$_PP_CONF['image_dir']}/{$prow['filename']}")) {
                 if ($i == 0) {
                     $T->set_var('main_img', PAYPAL_ImageUrl($prow['filename'], $tpl_config['lg_img_width'] - 20, $tpl_config['lg_img_height'] - 20));
                 }
                 $T->set_block('product', 'Thumbnail', 'PBlock');
                 $T->set_var(array('img_file' => $prow['filename'], 'disp_img' => PAYPAL_ImageUrl($prow['filename'], $tpl_config['lg_img_width'] - 20, $tpl_config['lg_img_height'] - 20), 'lg_img' => PAYPAL_URL . '/images/products/' . $prow['filename'], 'img_url' => PAYPAL_URL . '/images/products', 'thumb_url' => PAYPAL_ImageUrl($prow['filename']), 'tn_width' => $_PP_CONF['max_thumb_size'], 'tn_height' => $_PP_CONF['max_thumb_size']));
                 $T->parse('PBlock', 'Thumbnail', true);
             }
         }
     }
     // Get the product options, if any, and set them into the form
     $cbrk = '';
     $T->set_block('product', 'AttrSelect', 'attrSel');
     foreach ($this->options as $id => $Attr) {
         /*if ($Attr['attr_value'] === '') {
               $type = 'text';
           } else {
               $type = 'select';
           }*/
         $type = 'select';
         if ($Attr['attr_name'] != $cbrk) {
             if ($cbrk != '') {
                 // end block if not the first element
                 $T->set_var(array('attr_name' => $cbrk, 'attr_options' => $attributes, 'opt_id' => $id));
                 $T->parse('attrSel', 'AttrSelect', true);
             }
             $cbrk = $Attr['attr_name'];
             $attributes = '';
         }
         if ($type == 'select') {
             if ($Attr['attr_price'] != 0) {
                 $attr_str = sprintf(" ( %+.2f )", $Attr['attr_price']);
             } else {
                 $attr_str = '';
             }
             $attributes .= '<option value="' . $id . '|' . $Attr['attr_value'] . '|' . $Attr['attr_price'] . '">' . $Attr['attr_value'] . $attr_str . '</option>' . LB;
             /*} else {
                   $attributes .= "<input type=\"hidden\" name=\"on{$i}\" 
                           value=\"{$Attr['attr_name']}\">\n";
                   $attributes .= $Attr['attr_name'] . ':</td>
                       <td><input class="uk-contrast uk-form" type"text" name="os' . $i. '" value="" size="32" /></td></tr>';
               */
         }
     }
     if ($cbrk != '') {
         // finish off the last selection
         $T->set_var(array('attr_name' => $cbrk, 'attr_options' => $attributes, 'opt_id' => $id));
         $T->parse('attrSel', 'AttrSelect', true);
     }
     $buttons = $this->PurchaseLinks();
     $T->set_block('product', 'BtnBlock', 'Btn');
     foreach ($buttons as $name => $html) {
         if ($name == 'add_cart') {
             // Set the add to cart button in the main form
             $T->set_var('add_cart_button', $html);
         } else {
             $T->set_var('buy_now_button', $html);
             $T->parse('Btn', 'BtnBlock', true);
         }
     }
     // Show the user comments if enabled globally and for this product
     if (plugin_commentsupport_paypal() && $this->comments_enabled != PP_COMMENTS_DISABLED) {
         // if enabled or closed
         if ($_CONF['commentsloginrequired'] == 1 && COM_isAnonUser()) {
             // Set mode to "disabled"
             $mode = -1;
         } else {
             $mode = $this->comments_enabled;
         }
         $T->set_var('usercomments', CMT_userComments($prod_id, $this->short_description, 'paypal', '', '', 0, 1, false, false, $mode));
     }
     if ($this->rating_enabled == 1) {
         $PP_ratedIds = RATING_getRatedIds('paypal');
         if (in_array($prod_id, $PP_ratedIds)) {
             $static = true;
             $voted = 1;
         } elseif (plugin_canuserrate_paypal($A['id'], $_USER['uid'])) {
             $static = 0;
             $voted = 0;
         } else {
             $static = 1;
             $voted = 0;
         }
         $rating_box = RATING_ratingBar('paypal', $prod_id, $this->votes, $this->rating, $voted, 5, $static, 'sm');
         $T->set_var('rating_bar', $rating_box);
     } else {
         $T->set_var('ratign_bar', '');
     }
     if ($this->isAdmin) {
         // Add the quick-edit link for administrators
         $T->set_var(array('pi_admin_url' => PAYPAL_ADMIN_URL, 'can_edit' => 'true'));
     }
     $retval .= $T->parse('output', 'product');
     // Update the hit counter
     DB_query("UPDATE {$_TABLES['paypal.products']}\n                SET views = views + 1\n                WHERE id = '{$prod_id}'");
     $retval .= COM_endBlock();
     return $retval;
 }
Example #14
0
function showtopic($showtopic, $mode = '', $onetwo = 1, $page = 1)
{
    global $CONF_FORUM, $_CONF, $_TABLES, $_USER, $LANG_GF01, $LANG_GF02, $LANG_GF09;
    global $highlight;
    global $oldPost;
    $oldPost = 0;
    //$mytimer = new timerobject();
    //$mytimer->setPercision(2);
    //$mytimer->startTimer();
    //$intervalTime = $mytimer->stopTimer();
    //COM_errorLog("Show Topic Display Time1: $intervalTime");
    if (!class_exists('StringParser')) {
        require_once $CONF_FORUM['path_include'] . 'bbcode/stringparser_bbcode.class.php';
    }
    $topictemplate = COM_newTemplate(CTL_plugin_templatePath('forum'));
    $topictemplate->set_file(array('topictemplate' => 'topic.thtml', 'forum_icons' => 'forum_icons.thtml', 'forum_links' => 'forum_links.thtml'));
    $topictemplate->set_block('topictemplate', 'block_user_information');
    $topictemplate->set_block('topictemplate', 'block_anon_user_information');
    $topictemplate->set_block('topictemplate', 'location');
    $topictemplate->set_block('topictemplate', 'ip_address');
    $topictemplate->set_block('topictemplate', 'anon_ip_address');
    $topictemplate->set_block('topictemplate', 'user_signature');
    $topictemplate->set_block('topictemplate', 'mod_functions');
    $blocks = array('block_user_name', 'block_anon_user_name', 'block_user_information', 'block_anon_user_information', 'user_signature', 'mod_functions');
    foreach ($blocks as $block) {
        $topictemplate->set_block('topictemplate', $block);
    }
    $topictemplate->set_block('forum_icons', 'topiclocked_icon');
    $topictemplate->set_block('forum_icons', 'mood_icon');
    $blocks = array('profile_link', 'pm_link', 'email_link', 'website_link', 'quotetopic_link', 'edittopic_link');
    foreach ($blocks as $block) {
        $topictemplate->set_block('forum_links', $block);
    }
    // if preview, only stripslashes is gpc=on, else assume from db so strip
    if ($mode == 'preview') {
        $showtopic['subject'] = COM_stripslashes($showtopic['subject']);
    } else {
        $showtopic['subject'] = stripslashes($showtopic['subject']);
    }
    $min_height = 50;
    // Base minimum  height of topic - will increase if avatar or sig is used
    $date = strftime($CONF_FORUM['default_Topic_Datetime_format'], $showtopic['date']);
    $sql = "SELECT u.*, ui.location FROM {$_TABLES['users']} u, {$_TABLES['userinfo']} ui \n    \t\tWHERE u.uid = ui.uid \n    \t\tAND u.uid = '{$showtopic['uid']}'";
    $userQuery = DB_query($sql);
    if ($showtopic['uid'] > 1 and DB_numRows($userQuery) == 1) {
        $userarray = DB_fetchArray($userQuery);
        $username = COM_getDisplayName($showtopic['uid']);
        $userlink = "<a href=\"{$_CONF['site_url']}/users.php?mode=profile&amp;uid={$showtopic['uid']}\" ";
        $userlink .= "class=\"authorname {$onetwo}\"><b>{$username}</b></a>";
        $uservalid = true;
        $postcount = DB_query("SELECT * FROM {$_TABLES['forum_topic']} WHERE uid='{$showtopic['uid']}'");
        $posts = DB_numRows($postcount);
        // STARS CODE
        if (SEC_inGroup(1, $showtopic['uid'])) {
            $user_level = showrank(7, $LANG_GF01['admin']);
            $user_levelname = $LANG_GF01['admin'];
        } else {
            if (forum_modPermission($showtopic['forum'], $showtopic['uid'])) {
                $user_level = showrank(6, $LANG_GF01['moderator']);
                $user_levelname = $LANG_GF01['moderator'];
            } else {
                if ($posts < $CONF_FORUM['level2']) {
                    $user_level = showrank(1, $CONF_FORUM['level1name']);
                    $user_levelname = $CONF_FORUM['level1name'];
                } elseif ($posts >= $CONF_FORUM['level2'] && $posts < $CONF_FORUM['level3']) {
                    $user_level = showrank(2, $CONF_FORUM['level2name']);
                    $user_levelname = $CONF_FORUM['level2name'];
                } elseif ($posts >= $CONF_FORUM['level3'] && $posts < $CONF_FORUM['level4']) {
                    $user_level = showrank(3, $CONF_FORUM['level3name']);
                    $user_levelname = $CONF_FORUM['level3name'];
                } elseif ($posts >= $CONF_FORUM['level4'] && $posts < $CONF_FORUM['level5']) {
                    $user_level = showrank(4, $CONF_FORUM['level4name']);
                    $user_levelname = $CONF_FORUM['level4name'];
                } elseif ($posts > $CONF_FORUM['level5']) {
                    $user_level = showrank(5, $CONF_FORUM['level5name']);
                    $user_levelname = $CONF_FORUM['level5name'];
                }
            }
        }
        // Still allow photo to be showen for users
        if ($showtopic['uid'] > 1 and ($userarray['photo'] != "" or !empty($_CONF['default_photo']))) {
            $avatar = USER_getPhoto($showtopic['uid'], '', '', $CONF_FORUM['avatar_width']);
            $min_height = $min_height + 50;
        } else {
            $avatar = '';
        }
        $regdate = $LANG_GF01['REGISTERED'] . ': ' . strftime($_CONF['shortdate'], strtotime($userarray['regdate'])) . '<br' . XHTML . '>';
        $numposts = $LANG_GF01['POSTS'] . ': ' . $posts;
        if (DB_count($_TABLES['sessions'], 'uid', $showtopic['uid']) > 0 and DB_getItem($_TABLES['userprefs'], 'showonline', "uid={$showtopic['uid']}") == 1) {
            $avatar .= '<br' . XHTML . '>' . $LANG_GF01['STATUS'] . ' ' . $LANG_GF01['ONLINE'];
        } else {
            $avatar .= '<br' . XHTML . '>' . $LANG_GF01['STATUS'] . ' ' . $LANG_GF01['OFFLINE'];
        }
        if ($userarray['sig'] != '') {
            $sig = $userarray['sig'];
            $min_height = $min_height + 30;
        } else {
            $sig = '';
        }
    } else {
        $uservalid = false;
        $userlink = urldecode($showtopic['name']);
    }
    if ($CONF_FORUM['show_moods'] && $showtopic['mood'] != "") {
        $topictemplate->set_var('moodicon', gf_getImage($showtopic['mood'], 'moods'));
        $topictemplate->set_var('moodicontext', $showtopic['mood']);
        $topictemplate->parse('mood_icon', 'mood_icon');
        $min_height = $min_height + 30;
    } else {
        $topictemplate->set_var('mood_icon', '');
    }
    //$intervalTime = $mytimer->stopTimer();
    //COM_errorLog("Show Topic Display Time3: $intervalTime");
    // Handle Pre ver 2.5 quoting and New Line Formatting - consider adding this to a migrate function
    if ($CONF_FORUM['pre2.5_mode']) {
        // try to determine if we have an old post...
        if (strstr($showtopic['comment'], '<pre class="forumCode">') !== false) {
            $oldPost = 1;
        }
        if (strstr($showtopic['comment'], "[code]<code>") !== false) {
            $oldPost = 1;
        }
        if (strstr($showtopic['comment'], "<pre>") !== false) {
            $oldPost = 1;
        }
        if (stristr($showtopic['comment'], '[code') == false || stristr($showtopic['comment'], '[code]<code>') == true) {
            if (strstr($showtopic['comment'], "<pre>") !== false) {
                $oldPost = 1;
            }
            $showtopic['comment'] = str_replace('<pre>', '[code]', $showtopic['comment']);
            $showtopic['comment'] = str_replace('</pre>', '[/code]', $showtopic['comment']);
        }
        $showtopic['comment'] = str_ireplace("[code]<code>", '[code]', $showtopic['comment']);
        $showtopic['comment'] = str_ireplace("</code>[/code]", '[/code]', $showtopic['comment']);
        $showtopic['comment'] = str_replace(array("<br />\r\n", "<br />\n\r", "<br />\r", "<br />\n", "<br>\r\n", "<br>\n\r", "<br>\r", "<br>\n"), '<br' . XHTML . '>', $showtopic['comment']);
        $showtopic['comment'] = preg_replace("/\\[QUOTE\\sBY=\\s(.+?)\\]/i", "[QUOTE] Quote by \$1:", $showtopic['comment']);
        /* Reformat code blocks - version 2.3.3 and prior */
        $showtopic['comment'] = str_replace('<pre class="forumCode">', '[code]', $showtopic['comment']);
        $showtopic['comment'] = preg_replace("/\\[QUOTE\\sBY=(.+?)\\]/i", "[QUOTE] Quote by \$1:", $showtopic['comment']);
        if ($oldPost) {
            if (strstr($showtopic['comment'], "\\'") !== false) {
                $showtopic['comment'] = stripslashes($showtopic['comment']);
            }
        }
    }
    $showtopic['comment'] = gf_formatTextBlock($showtopic['comment'], $showtopic['postmode'], $mode);
    $showtopic['subject'] = gf_formatTextBlock($showtopic['subject'], 'text', $mode);
    if ($CONF_FORUM['show_subject_length'] > 0 and strlen($showtopic['subject']) > $CONF_FORUM['show_subject_length']) {
        $showtopic['subject'] = COM_truncate("{$showtopic['subject']}", $CONF_FORUM['show_subject_length'], '...');
    }
    //$intervalTime = $mytimer->stopTimer();
    //COM_errorLog("Show Topic Display Time2: $intervalTime");
    if ($mode != 'preview' && $uservalid && !COM_isAnonUser() && $_USER['uid'] == $showtopic['uid']) {
        /* Check if user can still edit this post - within allowed edit timeframe */
        $editAllowed = false;
        if ($CONF_FORUM['allowed_editwindow'] > 0) {
            $t1 = $showtopic['date'];
            $t2 = $CONF_FORUM['allowed_editwindow'];
            if (time() - $t2 < $t1) {
                $editAllowed = true;
            }
        } else {
            $editAllowed = true;
        }
        if ($editAllowed) {
            $editlink = "{$_CONF['site_url']}/forum/createtopic.php?method=edit&amp;forum={$showtopic['forum']}&amp;id={$showtopic['id']}&amp;editid={$showtopic['id']}&amp;page={$page}";
            $editlinktext = $LANG_GF09['edit'];
            $topictemplate->set_var('editlink', $editlink);
            $topictemplate->set_var('editlinktext', $editlinktext);
            $topictemplate->set_var('LANG_edit', $LANG_GF01['EDITICON']);
            $topictemplate->parse('edittopic_link', 'edittopic_link');
        }
    }
    if ($highlight != '') {
        $showtopic['subject'] = str_replace("{$highlight}", "<span class=\"highlight\">{$highlight}</span>", $showtopic['subject']);
        $showtopic['comment'] = str_replace("{$highlight}", "<span class=\"highlight\">{$highlight}</span>", $showtopic['comment']);
    }
    if (!isset($showtopic['pid'])) {
        $showtopic['pid'] = 0;
    }
    if ($showtopic['pid'] == 0) {
        $replytopicid = $showtopic['id'];
        $is_lockedtopic = $showtopic['locked'];
        $views = $showtopic['views'];
        $topictemplate->set_var('read_msg', sprintf($LANG_GF02['msg49'], $views));
        if ($is_lockedtopic) {
            $topictemplate->parse('topiclocked_icon', 'topiclocked_icon');
        }
    } else {
        $replytopicid = $showtopic['pid'];
        $is_lockedtopic = DB_getItem($_TABLES['forum_topic'], 'locked', "id={$showtopic['pid']}");
        $topictemplate->set_var('read_msg', '');
    }
    if ($CONF_FORUM['allow_user_dateformat']) {
        $date = COM_getUserDateTimeFormat($showtopic['date']);
        $topictemplate->set_var('posted_date', $date[0]);
    } else {
        $date = strftime($CONF_FORUM['default_Topic_Datetime_format'], $showtopic['date']);
        $topictemplate->set_var('posted_date', $date);
    }
    if ($mode != 'preview') {
        if ($is_lockedtopic == 0) {
            $is_readonly = DB_getItem($_TABLES['forum_forums'], 'is_readonly', 'forum_id=' . $showtopic['forum']);
            if ($is_readonly == 0 or forum_modPermission($showtopic['forum'], $_USER['uid'], 'mod_edit')) {
                $quotelink = "{$_CONF['site_url']}/forum/createtopic.php?method=postreply&amp;forum={$showtopic['forum']}&amp;id={$replytopicid}&amp;quoteid={$showtopic['id']}";
                $quotelinktext = $LANG_GF09['quote'];
                $topictemplate->set_var('quotelink', $quotelink);
                $topictemplate->set_var('quotelinktext', $quotelinktext);
                $topictemplate->set_var('LANG_quote', $LANG_GF01['QUOTEICON']);
                $topictemplate->parse('quotetopic_link', 'quotetopic_link');
            }
        }
        $topictemplate->set_var('topic_post_id', $showtopic['id']);
        if ($showtopic['uid'] > 1 && $uservalid) {
            $profile_link = "{$_CONF['site_url']}/users.php?mode=profile&amp;uid={$showtopic['uid']}";
            $profile_linktext = $LANG_GF09['profile'];
            $topictemplate->set_var('profilelink', $profile_link);
            $topictemplate->set_var('profilelinktext', $profile_linktext);
            $topictemplate->set_var('LANG_profile', $LANG_GF01['ProfileLink']);
            $topictemplate->parse('profile_link', 'profile_link');
            if ($CONF_FORUM['use_pm_plugin']) {
                $pmusernmame = COM_getDisplayName($showtopic['uid']);
                $pmplugin_link = forumPLG_getPMlink($pmusernmame);
                if ($pmplugin_link != '') {
                    $pm_link = $pmplugin_link;
                    $pm_linktext = $LANG_GF09['pm'];
                    $topictemplate->set_var('pmlink', $pm_link);
                    $topictemplate->set_var('pmlinktext', $pm_linktext);
                    $topictemplate->set_var('LANG_pm', $LANG_GF01['PMLink']);
                    $topictemplate->parse('pm_link', 'pm_link');
                }
            }
        }
        if ($userarray['email'] != '' && $showtopic["uid"] > 1) {
            $email_link = "{$_CONF['site_url']}/profiles.php?uid={$showtopic['uid']}";
            $email_linktext = $LANG_GF09['email'];
            $topictemplate->set_var('emaillink', $email_link);
            $topictemplate->set_var('emaillinktext', $email_linktext);
            $topictemplate->set_var('LANG_email', $LANG_GF01['EmailLink']);
            $topictemplate->parse('email_link', 'email_link');
        }
        if ($userarray['homepage'] != '') {
            $homepage = trim($userarray['homepage']);
            if (strtolower(substr($homepage, 0, 4)) != 'http') {
                $homepage = 'http://' . $homepage;
            }
            $homepagetext = $LANG_GF09['website'];
            $topictemplate->set_var('websitelink', $homepage);
            $topictemplate->set_var('websitelinktext', $homepagetext);
            $topictemplate->set_var('LANG_website', $LANG_GF01['WebsiteLink']);
            $topictemplate->parse('website_link', 'website_link');
        }
        if ($userarray['location'] != '' && $showtopic["uid"] > 1) {
            $topictemplate->set_var('user_location', $userarray['location']);
            $topictemplate->parse('location', 'location');
        }
    } else {
        if (isset($_GET['onlytopic']) and $_GET['onlytopic'] != 1) {
            $topictemplate->set_var('posted_date', '');
            $topictemplate->set_var('preview_topic_subject', $showtopic['subject']);
        } else {
            $topictemplate->set_var('preview_topic_subject', '');
        }
        $topictemplate->set_var('read_msg', '');
        $topictemplate->set_var('topiclocked_icon', '');
        $topictemplate->set_var('preview_mode', 'none');
    }
    //$intervalTime = $mytimer->stopTimer();
    //COM_errorLog("Show Topic Display Time4: $intervalTime");
    $showtopic['comment'] = str_replace('{', '&#123;', $showtopic['comment']);
    $showtopic['comment'] = str_replace('}', '&#125;', $showtopic['comment']);
    // Temporary correspondence. You should cope in more roots.
    $showtopic['comment'] = str_replace(array("<br />", "<br>"), '<br' . XHTML . '>', $showtopic['comment']);
    $topictemplate->set_var('layout_url', $CONF_FORUM['layout_url']);
    $topictemplate->set_var('csscode', $onetwo);
    $topictemplate->set_var('postmode', $showtopic['postmode']);
    $topictemplate->set_var('userlink', $userlink);
    $topictemplate->set_var('lang_forum', $LANG_GF01['FORUM']);
    $topictemplate->set_var('user_levelname', $user_levelname);
    $topictemplate->set_var('user_level', $user_level);
    $topictemplate->set_var('avatar', $avatar);
    $topictemplate->set_var('regdate', $regdate);
    $topictemplate->set_var('numposts', $numposts);
    if (forum_modPermission($showtopic['forum'], $_USER['uid'], 'mod_ban')) {
        $topictemplate->set_var('ip', $showtopic['ip']);
        if ($showtopic['uid'] == 1) {
            $topictemplate->parse('ip_address', 'anon_ip_address');
        } else {
            $topictemplate->parse('ip_address', 'ip_address');
        }
    } else {
        $topictemplate->set_var('ip_address', '');
    }
    $topictemplate->set_var('imgset', $CONF_FORUM['imgset']);
    $topictemplate->set_var('topic_subject', $showtopic['subject']);
    $topictemplate->set_var('LANG_ON2', $LANG_GF01['ON2']);
    if ($mode != 'preview') {
        $mod_functions = forum_getmodFunctions($showtopic);
        if (!empty($mod_functions)) {
            $topictemplate->set_var('mod_functions', $mod_functions);
            $topictemplate->parse('mod_functions', 'mod_functions');
        } else {
            $topictemplate->set_var('mod_functions', '');
        }
    }
    $topictemplate->set_var('topic_comment', $showtopic['comment']);
    $topictemplate->set_var('comment_minheight', "min-height:{$min_height}px");
    if (trim($sig) != '') {
        $topictemplate->set_var('sig', PLG_replaceTags($sig));
        $topictemplate->set_var('show_sig', '');
        $topictemplate->parse('user_signature', 'user_signature');
    } else {
        $topictemplate->set_var('sig', '');
        $topictemplate->set_var('show_sig', 'none');
        $topictemplate->set_var('user_signature', '');
    }
    $topictemplate->set_var('forumid', $showtopic['forum']);
    $topictemplate->set_var('topic_id', $showtopic['id']);
    $topictemplate->set_var('member_badge', forumPLG_getMemberBadge($showtopic['uid']));
    if ($uservalid) {
        $topictemplate->parse('user_name', 'block_user_name');
        $topictemplate->parse('user_information', 'block_user_information');
    } else {
        $topictemplate->parse('user_name', 'block_anon_user_name');
        $topictemplate->parse('user_information', 'block_anon_user_information');
    }
    $topictemplate->parse('output', 'topictemplate');
    $retval = $topictemplate->finish($topictemplate->get_var('output'));
    //$intervalTime = $mytimer->stopTimer();
    //COM_errorLog("Show Topic Display Time5: $intervalTime");
    return $retval;
}
Example #15
0
 /**
  *   Display the detail page for the event occurrence.
  *
  *   @param  integer $rp_id  ID of the repeat to display
  *   @param  string  $query  Optional query string, for highlighting
  *   @param  string  $tpl    Optional template filename, e.g. 'event_print'
  *   @return string      HTML for the page.
  */
 public function Render($rp_id = 0, $query = '', $tpl = '')
 {
     global $_CONF, $_USER, $_EV_CONF, $_TABLES, $LANG_EVLIST, $LANG_WEEK, $_SYSTEM;
     $retval = '';
     $url = '';
     $location = '';
     $street = '';
     $city = '';
     $province = '';
     $country = '';
     $postal = '';
     $name = '';
     $email = '';
     $phone = '';
     if ($rp_id != 0) {
         $this->Read($rp_id);
     }
     if ($this->rp_id == 0) {
         return EVLIST_alertMessage($LANG_EVLIST['access_denied']);
     }
     //update hit count
     evlist_hit($this->ev_id);
     $template = 'event';
     if (!empty($tpl)) {
         $template .= '_' . $tpl;
     } else {
         $template .= $_SYSTEM['framework'] == 'uikit' ? '.uikit' : '';
     }
     $T = new Template(EVLIST_PI_PATH . '/templates/');
     $T->set_file(array('event' => $template . '.thtml', 'datetime' => 'date_time.thtml', 'address' => 'address.thtml', 'contact' => 'contact.thtml'));
     // If plain text then replace newlines with <br> tags
     if ($this->Event->postmode == '1') {
         //plaintext
         $this->Event->Detail->summary = nl2br($this->Event->Detail->summary);
         $this->Event->Detail->full_description = nl2br($this->Event->Detail->full_description);
         $this->Event->Detail->location = nl2br($this->Event->Detail->location);
     }
     $title = $this->Event->Detail->title;
     if ($this->postmode != 'plaintext') {
         $summary = PLG_replaceTags($this->Event->Detail->summary);
         $fulldescription = PLG_replaceTags($this->Event->Detail->full_description);
         $location = $this->Event->Detail->location != '' ? PLG_replaceTags($this->Event->Detail->location) : '';
     } else {
         $summary = $this->Event->Detail->summary;
         $fulldescription = $this->Event->Detail->full_description;
         $location = $this->Event->Detail->location;
     }
     if ($query != '') {
         $title = COM_highlightQuery($title, $query);
         if (!empty($summary)) {
             $summary = COM_highlightQuery($summary, $query);
         }
         if (!empty($fulldescription)) {
             $fulldescription = COM_highlightQuery($fulldescription, $query);
         }
         if (!empty($location)) {
             $location = COM_highlightQuery($location, $query);
         }
     }
     $date_start = EVLIST_formattedDate($this->date_start);
     if ($this->date_start != $this->date_end) {
         $date_end = EVLIST_formattedDate($this->date_end);
     } else {
         $date_end = '';
     }
     if ($this->Event->allday == '1') {
         $allday = '<br />' . $LANG_EVLIST['all_day_event'];
     } else {
         $allday = '';
         if ($this->time_start1 != '') {
             $time_start1 = EVLIST_formattedTime($this->time_start1);
             $time_end1 = EVLIST_formattedTime($this->time_end1);
         } else {
             $time_start1 = '';
             $time_end1 = '';
         }
         //$time_period = $time_start . $time_end;
         if ($this->Event->split == '1') {
             $time_start2 = EVLIST_formattedTime($this->time_start2);
             $time_end2 = EVLIST_formattedTime($this->time_end2);
         }
     }
     $url = $this->Event->Detail->url;
     $street = $this->Event->Detail->street;
     $city = $this->Event->Detail->city;
     $province = $this->Event->Detail->province;
     $postal = $this->Event->Detail->postal;
     $country = $this->Event->Detail->country;
     // Now get the text description of the recurring interval, if any
     if ($this->Event->recurring && $this->Event->rec_data['type'] < EV_RECUR_DATES) {
         $rec_data = $this->Event->rec_data;
         $rec_string = $LANG_EVLIST['recur_freq_txt'] . ' ' . $this->Event->RecurDescrip();
         switch ($rec_data['type']) {
             case EV_RECUR_WEEKLY:
                 // sequential days
                 $weekdays = array();
                 if (is_array($rec_data['listdays'])) {
                     foreach ($rec_data['listdays'] as $daynum) {
                         $weekdays[] = $LANG_WEEK[$daynum];
                     }
                     $days_text = implode(', ', $weekdays);
                 } else {
                     $days_text = '';
                 }
                 $rec_string .= ' ' . sprintf($LANG_EVLIST['on_days'], $days_text);
                 break;
             case EV_RECUR_DOM:
                 $days = array();
                 foreach ($rec_data['interval'] as $key => $day) {
                     $days[] = $LANG_EVLIST['rec_intervals'][$day];
                 }
                 $days_text = implode(', ', $days) . ' ' . $LANG_WEEK[$rec_data['weekday']];
                 $rec_string .= ' ' . sprintf($LANG_EVLIST['on_the_days'], $days_text);
                 break;
         }
         if ($this->Event->rec_data['stop'] != '' && $this->Event->rec_data['stop'] < EV_MAX_DATE) {
             $rec_string .= ' ' . sprintf($LANG_EVLIST['recur_stop_desc'], EVLIST_formattedDate($this->Event->rec_data['stop']));
         }
     } else {
         $rec_string = '';
     }
     $T->set_var(array('pi_url' => EVLIST_URL, 'webcal_url' => preg_replace('/^https?/', 'webcal', EVLIST_URL), 'rp_id' => $this->rp_id, 'ev_id' => $this->ev_id, 'title' => $title, 'summary' => $summary, 'full_description' => $fulldescription, 'can_edit' => $this->isAdmin ? 'true' : '', 'start_time1' => $time_start1, 'end_time1' => $time_end1, 'start_time2' => $time_start2, 'end_time2' => $time_end2, 'start_date' => $date_start, 'end_date' => $date_end, 'start_datetime1' => $date_start . $time_start, 'end_datetime1' => $date_end . $time_end, 'allday_event' => $this->Event->allday == 1 ? 'true' : '', 'is_recurring' => $this->Event->recurring, 'can_subscribe' => $this->Event->Calendar->cal_ena_ical, 'recurring_event' => $rec_string, 'owner_id' => $this->Event->owner_id, 'cal_name' => $this->Event->Calendar->cal_name, 'cal_id' => $this->Event->cal_id, 'site_name' => $_CONF['site_name'], 'site_slogan' => $_CONF['site_slogan'], 'more_info_link' => sprintf($LANG_EVLIST['click_here'], $url)));
     if ($_EV_CONF['enable_rsvp'] == 1 && $this->Event->options['use_rsvp'] > 0) {
         if ($this->Event->options['rsvp_cutoff'] > 0) {
             $dt = new Date($this->event->date_start1 . ' ' . $this->Event->time_start1, $_CONF['timezone']);
             if (time() > $dt->toUnix() - $this->Event->options['rsvp_cutoff'] * 86400) {
                 $past_cutoff = false;
             } else {
                 $past_cutoff = true;
             }
         }
         if (COM_isAnonUser()) {
             // Just show a must-log-in message
             $T->set_var('login_to_register', 'true');
         } elseif (!$past_cutoff) {
             $num_free_tickets = $this->isRegistered(0, true);
             $total_tickets = $this->isRegistered(0, false);
             if ($num_free_tickets > 0) {
                 // If the user is already registered for any free tickets,
                 // show the cancel link
                 $T->set_var(array('unregister_link' => 'true', 'num_free_reg' => $num_free_tickets));
             }
             // Show the registration link
             if (($this->Event->options['max_rsvp'] == 0 || $this->Event->options['rsvp_waitlist'] == 1 || $this->Event->options['max_rsvp'] > $this->TotalRegistrations()) && ($this->Event->options['max_user_rsvp'] == 0 || $total_tickets < $this->Event->options['max_user_rsvp'])) {
                 USES_evlist_class_tickettype();
                 $Ticks = evTicketType::GetTicketTypes();
                 if ($this->Event->options['max_user_rsvp'] > 0) {
                     $T->set_block('event', 'tickCntBlk', 'tcBlk');
                     $T->set_var('register_multi', true);
                     //$rsvp_user_count = '';
                     $avail_tickets = $this->Event->options['max_user_rsvp'] - $total_tickets;
                     for ($i = 1; $i <= $avail_tickets; $i++) {
                         $T->set_var('tick_cnt', $i);
                         $T->parse('tcBlk', 'tickCntBlk', true);
                         //$rsvp_user_count .= '<option value="'.$i.'">'.$i.
                         //        '</option>'.LB;
                     }
                     //$T->set_var('register_multi', $rsvp_user_count);
                 } else {
                     // max_rsvp == 0 indicates openended registration
                     $T->set_var('register_unltd', 'true');
                 }
                 $T->set_block('event', 'tickTypeBlk', 'tBlk');
                 foreach ($this->Event->options['tickets'] as $tick_id => $data) {
                     /*$options .= '<option value="' . $tick_id . '">' .
                           $Ticks[$tick_id]->description;
                       if ($data['fee'] > 0) {
                           $options .= ' - ' . COM_numberFormat($data['fee'], 2);
                       }
                       $options .= '</option>' . LB;*/
                     $status = LGLIB_invokeService('paypal', 'formatAmount', array('amount' => $data['fee']), $pp_fmt_amt, $svc_msg);
                     $fmt_amt = $status == PLG_RET_OK ? $pp_fmt_amt : COM_numberFormat($data['fee'], 2);
                     $T->set_var(array('tick_type' => $tick_id, 'tick_descr' => $Ticks[$tick_id]->description, 'tick_fee' => $data['fee'] > 0 ? $fmt_amt : 'FREE'));
                     $T->parse('tBlk', 'tickTypeBlk', true);
                 }
                 $T->set_var(array('register_link' => 'true', 'ticket_options' => $options, 'ticket_types_multi' => count($this->Event->options['tickets']) > 1 ? 'true' : ''));
             }
         }
         // If ticket printing is enabled for this event, see if the
         // current user has any tickets to print.
         if ($this->Event->options['rsvp_print'] > 0) {
             $paid = $this->Event->options['rsvp_print'] == 1 ? 'paid' : '';
             USES_evlist_class_ticket();
             $tickets = evTicket::GetTickets($this->ev_id, '', $this->uid, $paid);
             if (count($tickets) > 0) {
                 $T->set_var('have_tickets', 'true');
             }
         }
     }
     // if enable_rsvp
     if (!empty($date_start) || !empty($date_end)) {
         $T->parse('datetime_info', 'datetime');
     }
     // Only process the location block if at least one element exists.
     // Don't want an empty block showing.
     if (!empty($location) || !empty($street) || !empty($city) || !empty($province) || !empty($postal)) {
         $T->set_var(array('location' => $location, 'street' => $street, 'city' => $city, 'province' => $province, 'country' => $country, 'postal' => $postal));
         $T->parse('address_info', 'address');
         // Get info from the Weather plugin, if configured and available
         // There has to be at least some location data for this to work.
         if ($_EV_CONF['use_weather']) {
             // The postal code works best, but not internationally.
             // Try the regular address first.
             $loc = '';
             if (!empty($city) && !empty($province)) {
                 $loc = $city . ', ' . $province . ' ' . $country;
             }
             if (!empty($postal)) {
                 $loc .= ' ' . $postal;
             }
             if (!empty($loc)) {
                 // Location info was found, get the weather
                 LGLIB_invokeService('weather', 'embed', array('loc' => $loc), $weather, $svc_msg);
                 if (!empty($weather)) {
                     // Weather info was found
                     $T->set_var('weather', $weather);
                 }
             }
         }
     }
     // Get a map from the Locator plugin, if configured and available
     if ($_EV_CONF['use_locator'] == 1 && $this->Event->Detail->lat != 0 && $this->Event->Detail->lng != 0) {
         $status = LGLIB_invokeService('locator', 'getMap', array('lat' => $this->Event->Detail->lat, 'lng' => $this->Event->Detail->lng), $map, $svc_msg);
         if ($status == PLG_RET_OK) {
             $T->set_var(array('map' => $map, 'lat' => number_format($this->Event->Detail->lat, 8, '.', ''), 'lng' => number_format($this->Event->Detail->lng, 8, '.', '')));
         }
     }
     //put contact info here: contact, email, phone#
     $name = $this->Event->Detail->contact != '' ? COM_applyFilter($this->Event->Detail->contact) : '';
     if ($this->Event->Detail->email != '') {
         $email = COM_applyFilter($this->Event->Detail->email);
         $email = EVLIST_obfuscate($email);
     } else {
         $email = '';
     }
     $phone = $this->Event->Detail->phone != '' ? COM_applyFilter($this->Event->Detail->phone) : '';
     if (!empty($name) || !empty($email) || !empty($phone)) {
         $T->set_var(array('name' => $name, 'email' => $email, 'phone' => $phone));
         $T->parse('contact_info', 'contact');
     }
     // TODO: Is the range needed?
     if (!empty($range)) {
         $andrange = '&amp;range=' . $range;
     } else {
         $andrange = '&amp;range=2';
     }
     if (!empty($cat)) {
         $andcat = '&amp;cat=' . $cat;
     } else {
         $andcat = '';
     }
     $cats = $this->Event->GetCategories();
     $catcount = count($cats);
     if ($catcount > 0) {
         $catlinks = array();
         for ($i = 0; $i < $catcount; $i++) {
             $catlinks[] = '<a href="' . COM_buildURL(EVLIST_URL . '/index.php?op=list' . $andrange . '&cat=' . $cats[$i]['id']) . '">' . $cats[$i]['name'] . '</a>&nbsp;';
         }
         $catlink = join('|&nbsp;', $catlinks);
         $T->set_var('category_link', $catlink, true);
     }
     //  reminders must be enabled globally first and then per event in
     //  order to be active
     if (!isset($_EV_CONF['reminder_days'])) {
         $_EV_CONF['reminder_days'] = 1;
     }
     $hasReminder = 0;
     if ($_EV_CONF['enable_reminders'] == '1' && $this->Event->enable_reminders == '1' && time() < strtotime("-" . $_EV_CONF['reminder_days'] . " days", strtotime($this->date_start))) {
         //form will not appear within XX days of scheduled event.
         $show_reminders = true;
         // Let's see if we have already asked for a reminder...
         if ($_USER['uid'] > 1) {
             $hasReminder = DB_count($_TABLES['evlist_remlookup'], array('eid', 'uid', 'rp_id'), array($this->ev_id, $_USER['uid'], $this->rp_id));
         }
     } else {
         $show_reminders = false;
     }
     if ($this->Event->options['contactlink'] == 1) {
         $ownerlink = $_CONF['site_url'] . '/profiles.php?uid=' . $this->Event->owner_id;
         $ownerlink = sprintf($LANG_EVLIST['contact_us'], $ownerlink);
     } else {
         $ownerlink = '';
     }
     $T->set_var(array('owner_link' => $ownerlink, 'reminder_set' => $hasReminder ? 'true' : 'false', 'reminder_email' => isset($_USER['email']) ? $_USER['email'] : '', 'notice' => 1, 'rp_id' => $this->rp_id, 'eid' => $this->ev_id, 'show_reminderform' => $show_reminders ? 'true' : ''));
     USES_evlist_class_tickettype();
     $tick_types = evTicketType::GetTicketTypes();
     $T->set_block('event', 'registerBlock', 'rBlock');
     if (is_array($this->Event->options['tickets'])) {
         foreach ($this->Event->options['tickets'] as $tic_type => $info) {
             $T->set_var(array('tic_description' => $tick_types[$tic_type]->description, 'tic_fee' => COM_numberFormat($info['fee'], 2)));
             $T->parse('rBlock', 'registerBlock', true);
         }
     }
     // Show the "manage reservations" link to the event owner
     if ($_EV_CONF['enable_rsvp'] == 1 && $this->Event->options['use_rsvp'] > 0) {
         if ($this->isAdmin) {
             $T->set_var('admin_rsvp', EVLIST_adminRSVP($this->rp_id));
         }
     }
     $T->parse('output', 'event');
     $retval .= $T->finish($T->get_var('output'));
     return $retval;
 }
Example #16
0
/**
* Saves a block
*
* @param    string  $bid            Block ID
* @param    string  $title          Block title
* @param    string  $type           Type of block
* @param    int     $blockorder     Order block appears relative to the others
* @param    string  $content        Content of block
* @param    string  $tid            Ids of topics block is assigned to
* @param    string  $rdfurl         URL to headline feed for portal blocks
* @param    string  $rdfupdated     Date RSS/RDF feed was last updated
* @param    string  $rdflimit       max. number of entries to import from feed
* @param    string  $phpblockfn     Name of php function to call to get content
* @param    int     $onleft         Flag indicates if block shows up on left or right
* @param    int     $owner_id       ID of owner
* @param    int     $group_id       ID of group block belongs to
* @param    array   $perm_owner     Permissions the owner has on the object
* @param    array   $perm_group     Permissions the group has on the object
* @param    array   $perm_members   Permissions the logged in members have
* @param    array   $perm_anon      Permissinos anonymous users have
* @param    int     $is_enabled     Flag, indicates if block is enabled or not
* @return   string                  HTML redirect or error message
*
*/
function saveblock($bid, $name, $title, $help, $type, $blockorder, $content, $rdfurl, $rdfupdated, $rdflimit, $phpblockfn, $onleft, $owner_id, $group_id, $perm_owner, $perm_group, $perm_members, $perm_anon, $is_enabled, $allow_autotags, $cache_time)
{
    global $_CONF, $_TABLES, $LANG01, $LANG21, $MESSAGE, $_USER;
    $retval = '';
    $title = DB_escapeString(COM_stripslashes(strip_tags($title)));
    $phpblockfn = DB_escapeString(COM_stripslashes(trim($phpblockfn)));
    if (empty($title) || !TOPIC_checkTopicSelectionControl()) {
        $retval .= COM_showMessageText($LANG21[64], $LANG21[63]) . editblock($bid);
        $retval = COM_createHTMLDocument($retval, array('pagetitle' => $LANG21[63]));
        return $retval;
    }
    // Convert array values to numeric permission values
    list($perm_owner, $perm_group, $perm_members, $perm_anon) = SEC_getPermissionValues($perm_owner, $perm_group, $perm_members, $perm_anon);
    $access = 0;
    if ($bid > 0 && DB_count($_TABLES['blocks'], 'bid', $bid) > 0) {
        $result = DB_query("SELECT owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon FROM {$_TABLES['blocks']} WHERE bid = '{$bid}'");
        $A = DB_fetchArray($result);
        $access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']);
    } else {
        $access = SEC_hasAccess($owner_id, $group_id, $perm_owner, $perm_group, $perm_members, $perm_anon);
    }
    if ($access < 3 || !TOPIC_hasMultiTopicAccess('topic') || !SEC_inGroup($group_id)) {
        $retval .= COM_showMessageText($MESSAGE[29], $MESSAGE[30]);
        $retval = COM_createHTMLDocument($retval, array('pagetitle' => $MESSAGE[30]));
        COM_accessLog("User {$_USER['username']} tried to illegally create or edit block {$bid}.");
        return $retval;
    } elseif (!empty($name) and ($type == 'normal' && !empty($title) && !empty($content) or $type == 'portal' && !empty($title) && !empty($rdfurl) or $type == 'phpblock' && !empty($phpblockfn) && !empty($title) or $type == 'gldefault' && strlen($blockorder) > 0)) {
        if ($is_enabled == 'on') {
            $is_enabled = 1;
        } else {
            $is_enabled = 0;
        }
        if ($allow_autotags == 'on') {
            $allow_autotags = 1;
        } else {
            $allow_autotags = 0;
        }
        if ($cache_time < -1 or $cache_time == "") {
            $cache_time = $_CONF['default_cache_time_block'];
        }
        if ($type == 'portal') {
            $content = '';
            $rdfupdated = '';
            $phpblockfn = '';
            // get rid of possible extra prefixes (e.g. "feed://http://...")
            if (substr($rdfurl, 0, 4) == 'rss:') {
                $rdfurl = substr($rdfurl, 4);
            } elseif (substr($rdfurl, 0, 5) == 'feed:') {
                $rdfurl = substr($rdfurl, 5);
            }
            if (substr($rdfurl, 0, 2) == '//') {
                $rdfurl = substr($rdfurl, 2);
            }
            $rdfurl = COM_sanitizeUrl($rdfurl, array('http', 'https'));
        }
        if ($type == 'gldefault') {
            $content = '';
            $rdfurl = '';
            $rdfupdated = '';
            $rdflimit = 0;
            $phpblockfn = '';
        }
        if ($type == 'phpblock') {
            // NOTE: PHP Blocks must be within a function and the function
            // must start with phpblock_ as the prefix.  This will prevent
            // the arbitrary execution of code
            if (!stristr($phpblockfn, 'phpblock_')) {
                $retval .= COM_showMessageText($LANG21[38], $LANG21[37]) . editblock($bid);
                $retval = COM_createHTMLDocument($retval, array('pagetitle' => $LANG21[37]));
                return $retval;
            }
            $content = '';
            $rdfurl = '';
            $rdfupdated = '';
            $rdflimit = 0;
        }
        if ($type == 'normal') {
            $rdfurl = '';
            $rdfupdated = '';
            $rdflimit = 0;
            $phpblockfn = '';
            if ($allow_autotags == 1) {
                // Remove any autotags the user doesn't have permission to use
                $content = PLG_replaceTags($content, '', true);
            }
            $content = DB_escapeString($content);
        }
        if ($rdflimit < 0) {
            $rdflimit = 0;
        }
        if (!empty($rdfurl)) {
            $rdfurl = DB_escapeString($rdfurl);
        }
        if (empty($rdfupdated)) {
            $rdfupdated = '0000-00-00 00:00:00';
        }
        if ($bid > 0) {
            DB_save($_TABLES['blocks'], 'bid,name,title,help,type,blockorder,content,rdfurl,rdfupdated,rdflimit,phpblockfn,onleft,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon,is_enabled,allow_autotags,cache_time,rdf_last_modified,rdf_etag', "{$bid},'{$name}','{$title}','{$help}','{$type}','{$blockorder}','{$content}','{$rdfurl}','{$rdfupdated}','{$rdflimit}','{$phpblockfn}',{$onleft},{$owner_id},{$group_id},{$perm_owner},{$perm_group},{$perm_members},{$perm_anon},{$is_enabled},{$allow_autotags},{$cache_time},NULL,NULL");
        } else {
            $sql = array();
            $sql['mysql'] = $sql['mssql'] = "INSERT INTO {$_TABLES['blocks']} " . '(name,title,help,type,blockorder,content,rdfurl,rdfupdated,rdflimit,phpblockfn,onleft,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon,is_enabled,allow_autotags,cache_time) ' . "VALUES ('{$name}','{$title}','{$help}','{$type}','{$blockorder}','{$content}','{$rdfurl}','{$rdfupdated}','{$rdflimit}','{$phpblockfn}',{$onleft},{$owner_id},{$group_id},{$perm_owner},{$perm_group},{$perm_members},{$perm_anon},{$is_enabled},{$allow_autotags},{$cache_time})";
            $sql['pgsql'] = "INSERT INTO {$_TABLES['blocks']} " . '(bid,name,title,help,type,blockorder,content,rdfurl,rdfupdated,rdflimit,phpblockfn,onleft,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon,is_enabled,allow_autotags,cache_time) ' . "VALUES ((SELECT NEXTVAL('{$_TABLES['blocks']}_bid_seq')),'{$name}','{$title}','{$help}','{$type}','{$blockorder}','{$content}','{$rdfurl}','1970-01-01','{$rdflimit}','{$phpblockfn}',{$onleft},{$owner_id},{$group_id},{$perm_owner},{$perm_group},{$perm_members},{$perm_anon},{$is_enabled},{$allow_autotags},{$cache_time})";
            DB_query($sql);
            $bid = DB_insertId();
        }
        TOPIC_saveTopicSelectionControl('block', $bid);
        $cacheInstance = 'block__' . $bid . '__';
        // remove any of this blocks instances if exists
        CACHE_remove_instance($cacheInstance);
        return COM_refresh($_CONF['site_admin_url'] . '/block.php?msg=11');
    } else {
        if (empty($name)) {
            // empty block name
            $msgtxt = $LANG21[50];
        } elseif ($type == 'portal') {
            // Portal block is missing fields
            $msgtxt = $LANG21[33];
        } elseif ($type == 'phpblock') {
            // PHP Block is missing field
            $msgtxt = $LANG21[34];
        } elseif ($type == 'normal') {
            // Normal block is missing field
            $msgtxt = $LANG21[35];
        } elseif ($type == 'gldefault') {
            // Default geeklog field missing
            $msgtxt = $LANG21[42];
        } else {
            // Layout block missing content
            $msgtxt = $LANG21[36];
        }
        $retval .= COM_showMessageText($msgtxt, $LANG21[32]) . editblock($bid);
        $retval = COM_createHTMLDocument($retval, array('pagetitle' => $LANG21[32]));
    }
    return $retval;
}
Example #17
0
if ($total_print_pages == 0) {
    $total_print_pages = 1;
}
//$T = new Template($_CONF['path_html'] . $mb_base_path . '/templates');
$T = new Template($_CONF['path'] . 'plugins/ckeditor/templates/mediagallery');
$T->set_file(array('page' => 'mb.thtml', 'body' => 'mb_body.thtml'));
$birdseed = $MG_albums[$album_id]->getPath(0, '');
$refresh = isset($_REQUEST['refresh']) ? COM_applyFilter($_REQUEST['refresh'], true) : 0;
if ($refresh != 1) {
    // initial call
    $T->set_var(array('border_yes' => $_mgMB_CONF['at_border'] == 1 ? ' selected="selected"' : '', 'border_no' => $_mgMB_CONF['at_border'] == 1 ? '' : ' selected="selected"', 'algin_none' => $_mgMB_CONF['at_align'] == 'none' ? ' selected="selected"' : '', 'align_auto' => $_mgMB_CONF['at_align'] == 'auto' ? ' selected="selected"' : '', 'align_right' => $_mgMB_CONF['at_align'] == 'right' ? ' selected="selected"' : '', 'align_left' => $_mgMB_CONF['at_align'] == 'left' ? ' selected="selected"' : '', 'width' => $_mgMB_CONF['at_width'], 'height' => $_mgMB_CONF['at_height'], 'delay' => $_mgMB_CONF['at_delay'], 'src_tn' => $_mgMB_CONF['at_src'] == 'tn' ? ' selected="selected"' : '', 'src_disp' => $_mgMB_CONF['at_src'] == 'disp' ? ' selected="selected"' : '', 'src_orig' => $_mgMB_CONF['at_src'] == 'orig' ? ' selected="selected"' : '', 'autoplay_yes' => $_mgMB_CONF['at_autoplay'] == 1 ? ' selected="selected"' : '', 'autoplay_no' => $_mgMB_CONF['at_autoplay'] == 1 ? '' : ' selected="selected"', 'link_yes' => $_mgMB_CONF['at_enable_link'] == 1 ? ' selected="selected"' : '', 'link_no' => $_mgMB_CONF['at_enable_link'] == 1 ? '' : ' selected="selected"', 'alturl_no' => isset($_mgMB_CONF['at_alt_url']) && $_mgMB_CONF['at_alt_url'] == 1 ? '' : ' selected="selected"', 'alturl_yes' => isset($_mgMB_CONF['at_alt_url']) && $_mgMB_CONF['at_alt_url'] == 1 ? ' selected="selected"' : ''));
} else {
    $T->set_var(array('border_yes' => $_POST['border'] == 1 ? ' selected="selected"' : '', 'border_no' => $_POST['border'] == 1 ? '' : ' selected="selected"', 'align_none' => $_POST['alignment'] == 'none' ? ' selected="selected"' : '', 'align_auto' => $_POST['alignment'] == 'auto' ? ' selected="selected"' : '', 'align_right' => $_POST['alignment'] == 'right' ? ' selected="selected"' : '', 'align_left' => $_POST['alignment'] == 'left' ? ' selected="selected"' : '', 'width' => $_POST['width'], 'height' => $_POST['height'], 'delay' => isset($_POST['delay']) ? $_POST['delay'] : $_mgMB_CONF['at_delay'], 'src_tn' => $_POST['source'] == 'tn' ? ' selected="selected"' : '', 'src_disp' => $_POST['source'] == 'disp' ? ' selected="selected"' : '', 'src_orig' => $_POST['source'] == 'orig' ? ' selected="selected"' : '', 'autoplay_yes' => $_POST['autoplay'] == 1 ? ' selected="selected"' : '', 'autoplay_no' => $_POST['autoplay'] == 1 ? '' : ' selected="selected"', 'link_yes' => $_POST['link'] == 1 ? ' selected="selected"' : '', 'link_no' => $_POST['link'] == 1 ? '' : ' selected="selected"', 'alturl_yes' => $_POST['alturl'] == 1 ? ' selected="selected"' : '', 'alturl_no' => $_POST['alturl'] == 1 ? '' : ' selected="selected"', 'albumon' => $_POST['autotag'] == 'album' ? ' checked=checked' : '', 'slideshowon' => $_POST['autotag'] == 'slideshow' ? ' checked=checked' : '', 'fslideshowon' => $_POST['autotag'] == 'fslideshow' ? ' checked=checked' : '', 'mediaon' => $_POST['autotag'] == 'media' ? ' checked=checked' : '', 'mlinkon' => $_POST['autotag'] == 'mlink' ? ' checked=checked' : '', 'imgon' => $_POST['autotag'] == 'img' ? ' checked=checked' : '', 'videoon' => $_POST['autotag'] == 'video' ? ' checked=checked' : '', 'audioon' => $_POST['autotag'] == 'audio' ? 'checked=checked' : '', 'playallon' => $_POST['autotag'] == 'playall' ? 'checked=checked' : '', 'caption' => $_POST['caption']));
}
$self_url = @htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, COM_getEncodingt());
$T->set_var(array('s_form_action' => $self_url, 'site_url' => $_MG_CONF['site_url'], 'birdseed' => $birdseed, 'album_title' => PLG_replaceTags($MG_albums[$album_id]->title), 'table_columns' => $columns_per_page, 'table_column_width' => intval(100 / $columns_per_page) . '%', 'top_pagination' => COM_printPageNavigation($self_url . '?aid=' . $album_id . '&amp;i=' . $instance . '&amp;refresh=1', $page + 1, ceil($total_items_in_album / $media_per_page)), 'bottom_pagination' => COM_printPageNavigation($self_url . '?aid=' . $album_id . '&amp;i=' . $instance . '&amp;refresh=1', $page + 1, ceil($total_items_in_album / $media_per_page)), 'page_number' => sprintf("%s %d %s %d", $LANG_MG03['page'], $current_print_page, $LANG_MG03['of'], $total_print_pages), 'jumpbox' => $album_jumpbox_full, 'jumpbox_raw' => $album_jumpbox_raw, 'album_id' => $album_id, 'instance' => $instance, 'lang_menulabel' => $LANG_mgMB['menulabel'], 'lang_select_album' => $LANG_mgMB['select_album'], 'lang_go' => $LANG_mgMB['go'], 'lang_error_header' => $LANG_mgMB['error_header'], 'lang_current_album' => $LANG_mgMB['current_album'], 'lang_autotag_attr' => $LANG_mgMB['autotag_attr'], 'lang_album' => $LANG_mgMB['album'], 'lang_playall' => $LANG_mgMB['playall'], 'lang_slideshow' => $LANG_mgMB['slideshow'], 'lang_fslideshow' => $LANG_mgMB['fslideshow'], 'lang_media' => $LANG_mgMB['media'], 'lang_mlink' => $LANG_mgMB['mlink'], 'lang_img' => $LANG_mgMB['img'], 'lang_video' => $LANG_mgMB['video'], 'lang_audio' => $LANG_mgMB['audio'], 'lang_width' => $LANG_mgMB['width'], 'lang_height' => $LANG_mgMB['height'], 'lang_delay' => $LANG_mgMB['delay'], 'lang_border' => $LANG_mgMB['border'], 'lang_alignment' => $LANG_mgMB['alignment'], 'lang_source' => $LANG_mgMB['source'], 'lang_link' => $LANG_mgMB['link'], 'lang_autoplay' => $LANG_mgMB['autoplay'], 'lang_caption' => $LANG_mgMB['caption'], 'lang_thumbnails' => $LANG_mgMB['thumbnails'], 'lang_navigation' => $LANG_mgMB['navigation'], 'lang_insert' => $LANG_mgMB['insert'], 'lang_cancel' => $LANG_mgMB['cancel'], 'lang_yes' => $LANG_mgMB['yes'], 'lang_no' => $LANG_mgMB['no'], 'lang_auto' => $LANG_mgMB['auto'], 'lang_none' => $LANG_mgMB['none'], 'lang_right' => $LANG_mgMB['right'], 'lang_left' => $LANG_mgMB['left'], 'lang_thumbnail' => $LANG_mgMB['thumbnail'], 'lang_display' => $LANG_mgMB['display'], 'lang_original' => $LANG_mgMB['original'], 'lang_alturl' => $LANG_mgMB['alturl'], 'lang_ribbon' => $LANG_mgMB['ribbon'], 'lang_link_src' => $LANG_mgMB['link_src'], 'lang_showtitle' => $LANG_mgMB['showtitle'], 'lang_top' => $LANG_mgMB['top'], 'lang_bottom' => $LANG_mgMB['bottom'], 'destination' => $_mgMB_CONF['enable_dest'] == 1 ? '<p>' . $LANG_mgMB['destination'] . '&nbsp;&nbsp;<select name="dest"><option value="story">' . $LANG_mgMB['story'] . '</option><option value="block">' . $LANG_mgMB['block'] . '</option></select>' : '', 'lang_select_album' => $LANG_mgMB['select_album']));
if ($total_media == 0) {
    $T->set_var('lang_no_image', $LANG_MG03['no_media_objects']);
    $T->parse('album_noimages', 'noitems');
}
if ($total_media > 0) {
    $k = 0;
    $T->set_block('body', 'ImageDetail', 'IDetail');
    $T->set_block('body', 'ImageColumn', 'IColumn');
    $T->set_block('body', 'ImageRow', 'IRow');
    for ($i = 0; $i < $media_per_page; $i += $columns_per_page) {
        $T->set_var('IDetail', '');
        $T->set_var('IColumn', '');
        for ($j = $i; $j < $i + $columns_per_page; $j++) {
            if ($j >= $total_media) {
                $k = $i + $columns_per_page - $j;
Example #18
0
        $msg = $LANG_PAYPAL_1['thanks_details'];
        $msg .= '<p>' . $LANG_PAYPAL_1['transaction'] . ' ' . $_POST['txn_id'] . '</p>';
        $msg .= '<p>' . $LANG_PAYPAL_1['name_label'] . ' ' . $_POST['first_name'] . ' ' . $_POST['last_name'] . ' | ' . $LANG_PAYPAL_1['email'] . ' ' . $_POST['payer_email'] . '</p><ul>';
        for ($i = 1; $i <= $_POST['num_cart_items']; $i++) {
            $msg .= '<li>' . $_POST["quantity{$i}"] . 'x ' . $_POST["item_name{$i}"] . '... ' . $_POST["mc_gross_{$i}"] . ' ' . $_POST['mc_currency'];
        }
        $msg .= '</ul><p>' . $LANG_PAYPAL_1['total'] . ' ' . $_POST['mc_gross'] . ' ' . $_POST['mc_currency'] . '</p>';
        $display .= COM_showMessageText($msg, $LANG_PAYPAL_1['thanks']);
        $display .= '<div id="cart">' . PAYPAL_displayCart() . '</div>';
        $display .= PAYPAL_siteFooter();
        break;
    case 'cancel':
        $msg = $LANG_PAYPAL_1['cancel_details'];
        $display .= COM_showMessageText($msg, $LANG_PAYPAL_1['cancel']);
        $display .= PAYPAL_displayProducts('', 0, $_REQUEST['category']);
        $display .= '<div id="cart">' . PAYPAL_displayCart() . '</div>';
        $display .= PAYPAL_siteFooter();
        break;
    default:
        if ($_PAY_CONF['paypal_main_header'] != '' && $_REQUEST['category'] == '') {
            $display .= '<div>' . PLG_replaceTags($_PAY_CONF['paypal_main_header']) . '</div>';
        }
        $display .= PAYPAL_displayProducts('', 0, $_REQUEST['category']);
        if ($_PAY_CONF['paypal_main_footer'] != '') {
            $display .= '<div>' . PLG_replaceTags($_PAY_CONF['paypal_main_footer']) . '</div>';
        }
        //Display cart
        $display .= '<div id="cart">' . PAYPAL_displayCart() . '</div>';
        $display .= PAYPAL_siteFooter();
}
COM_output($display);
Example #19
0
function links_save_category($cid, $old_cid, $pid, $category, $description, $tid, $owner_id, $group_id, $perm_owner, $perm_group, $perm_members, $perm_anon)
{
    global $_CONF, $_TABLES, $_USER, $LANG_LINKS, $LANG_LINKS_ADMIN, $_LI_CONF, $PLG_links_MESSAGE17;
    // Convert array values to numeric permission values
    if (is_array($perm_owner) or is_array($perm_group) or is_array($perm_members) or is_array($perm_anon)) {
        list($perm_owner, $perm_group, $perm_members, $perm_anon) = SEC_getPermissionValues($perm_owner, $perm_group, $perm_members, $perm_anon);
    }
    // Remove any autotags the user doesn't have permission to use
    $description = PLG_replaceTags($description, '', true);
    // clean 'em up
    $description = DB_escapeString(COM_checkHTML(COM_checkWords($description), 'links.edit'));
    $category = DB_escapeString(COM_checkHTML(COM_checkWords($category), 'links.edit'));
    $pid = DB_escapeString(strip_tags($pid));
    $cid = DB_escapeString(strip_tags($cid));
    $old_cid = DB_escapeString(strip_tags($old_cid));
    if (empty($category) || empty($description)) {
        return 7;
    }
    // Check cid to make sure not illegal
    if ($cid == DB_escapeString($_LI_CONF['root']) || $cid == 'user') {
        return 11;
    }
    if (!empty($cid) && $cid != $old_cid) {
        // this is either a new category or an attempt to change the cid
        // - check that cid doesn't exist yet
        $ctrl = DB_getItem($_TABLES['linkcategories'], 'cid', "cid = '{$cid}'");
        if (!empty($ctrl)) {
            if (isset($PLG_links_MESSAGE17)) {
                return 17;
            } else {
                return 11;
            }
        }
    }
    // Check that they didn't delete the cid. If so, get the hidden one
    if (empty($cid) && !empty($old_cid)) {
        $cid = $old_cid;
    }
    // Make sure they aren't making a parent category child of one of it's own
    // children. This would create orphans
    if ($cid == DB_getItem($_TABLES['linkcategories'], 'pid', "cid='{$pid}'")) {
        return 12;
    }
    $access = 0;
    if (DB_count($_TABLES['linkcategories'], 'cid', $old_cid) > 0) {
        // update existing item, but new cid so get access from database with old cid
        $result = DB_query("SELECT owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon FROM {$_TABLES['linkcategories']} WHERE cid='{$old_cid}'");
        $A = DB_fetchArray($result);
        $access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']);
        // set flag
        $update = "existing";
    } else {
        if (DB_count($_TABLES['linkcategories'], 'cid', $cid) > 0) {
            // update existing item, same cid, so get access from database with existing cid
            $result = DB_query("SELECT owner_id,group_id,perm_owner,perm_group, perm_members,perm_anon FROM {$_TABLES['linkcategories']} WHERE cid='{$cid}'");
            $A = DB_fetchArray($result);
            $access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']);
            // set flag
            $update = "same";
        } else {
            // new item, so use passed values
            $access = SEC_hasAccess($owner_id, $group_id, $perm_owner, $perm_group, $perm_members, $perm_anon);
            // set flag
            $update = 'new';
        }
    }
    if ($access < 3) {
        // no access rights: user should not be here
        COM_accessLog(sprintf($LANG_LINKS_ADMIN[60], $_USER['username'], $cid));
        return 6;
    } else {
        // save item
        if ($update == 'existing') {
            // update an existing item but new cid
            $sql = "UPDATE {$_TABLES['linkcategories']}\n                    SET cid='{$cid}',\n                        pid='{$pid}',\n                        tid='{$tid}',category='{$category}',\n                        description='{$description}',\n                        modified=NOW(),\n                        owner_id='{$owner_id}',group_id='{$group_id}',\n                        perm_owner='{$perm_owner}',perm_group='{$perm_group}',\n                        perm_members='{$perm_members}',perm_anon='{$perm_anon}'\n                    WHERE cid = '{$old_cid}'";
            $result = DB_query($sql);
            // Also need to update links for this category
            $sql = "UPDATE {$_TABLES['links']} SET cid='{$cid}' WHERE cid='{$old_cid}'";
            $result = DB_query($sql);
        } else {
            if ($update == 'same') {
                // update an existing item
                $sql = "UPDATE {$_TABLES['linkcategories']}\n                    SET pid='{$pid}',\n                        tid='{$tid}',category='{$category}',\n                        description='{$description}',\n                        modified=NOW(),\n                        owner_id='{$owner_id}',group_id='{$group_id}',\n                        perm_owner='{$perm_owner}',perm_group='{$perm_group}',\n                        perm_members='{$perm_members}',perm_anon='{$perm_anon}'\n                    WHERE cid = '{$cid}'";
                $result = DB_query($sql);
            } else {
                // insert a new item
                if (empty($cid)) {
                    $cid = COM_makeSid();
                }
                $sql = "INSERT INTO {$_TABLES['linkcategories']}\n                    (cid, pid, category, description, tid,\n                    created,modified,\n                    owner_id, group_id, perm_owner, perm_group,\n                    perm_members, perm_anon)\n                    VALUES\n                    ('{$cid}','{$pid}','{$category}',\n                    '{$description}','{$tid}',\n                    NOW(),NOW(),\n                    '{$owner_id}','{$group_id}','{$perm_owner}',\n                    '{$perm_group}','{$perm_members}','{$perm_anon}')";
                $result = DB_query($sql);
            }
        }
        if ($update == 'existing' && $cid != $old_cid) {
            PLG_itemSaved($cid, 'links.category', $old_cid);
        } else {
            PLG_itemSaved($cid, 'links.category');
        }
    }
    return 10;
    // success message
}
Example #20
0
function showtopic($showtopic, $mode = '', $onetwo = 1, $page = 1)
{
    global $CONF_FORUM, $_CONF, $_TABLES, $_USER, $LANG_GF01, $LANG_GF02;
    global $fromblock, $highlight;
    global $oldPost, $forumfiles;
    $oldPost = 0;
    //$mytimer = new timerobject();
    //$mytimer->setPercision(2);
    //$mytimer->startTimer();
    //$intervalTime = $mytimer->stopTimer();
    //COM_errorLog("Show Topic Display Time1: $intervalTime");
    if (!class_exists('StringParser')) {
        require_once $_CONF['path_html'] . 'forum/include/bbcode/stringparser_bbcode.class.php';
    }
    $topictemplate = new Template($_CONF['path_layout'] . 'forum/layout');
    $topictemplate->set_file(array('topictemplate' => 'topic.thtml', 'profile' => 'links/profile.thtml', 'pm' => 'links/pm.thtml', 'email' => 'links/email.thtml', 'website' => 'links/website.thtml', 'quote' => 'links/quotetopic.thtml', 'edit' => 'links/edittopic.thtml'));
    // if preview, only stripslashes is gpc=on, else assume from db so strip
    if ($mode == 'preview') {
        $showtopic['subject'] = COM_stripslashes($showtopic['subject']);
        $topictemplate->set_var('show_topicrow1', 'none');
        $topictemplate->set_var('show_topicrule', 'none');
        $topictemplate->set_var('lang_postpreview', $LANG_GF01['PREVIEW_HEADER']);
    } else {
        $showtopic['subject'] = stripslashes($showtopic['subject']);
        $topictemplate->set_var('show_topicrow2', 'none');
    }
    $min_height = 50;
    // Base minimum  height of topic - will increase if avatar or sig is used
    $date = strftime($CONF_FORUM['default_Topic_Datetime_format'], $showtopic['date']);
    $userQuery = DB_query("SELECT * FROM {$_TABLES['users']} WHERE uid='{$showtopic['uid']}'");
    if ($showtopic['uid'] > 1 and DB_numRows($userQuery) == 1) {
        $userarray = DB_fetchArray($userQuery);
        $username = COM_getDisplayName($showtopic['uid']);
        $userlink = "<a href=\"{$_CONF['site_url']}/users.php?mode=profile&amp;uid={$showtopic['uid']}\" ";
        $userlink .= "class=\"authorname {$onetwo}\"><b>{$username}</b></a>";
        $uservalid = true;
        $postcount = DB_query("SELECT * FROM {$_TABLES['gf_topic']} WHERE uid='{$showtopic['uid']}'");
        $posts = DB_numRows($postcount);
        // STARS CODE
        $starimage = "<IMG SRC=\"%s\" ALT=\"{$LANG_GF01['FORUM']} %s\" TITLE=\"{$LANG_GF01['FORUM']} %s\">";
        if ($posts < $CONF_FORUM['level2']) {
            $user_level = sprintf($starimage, gf_getImage('rank1', 'ranks'), $CONF_FORUM['level1name'], $CONF_FORUM['level1name']);
            $user_levelname = $CONF_FORUM['level1name'];
        } elseif ($posts >= $CONF_FORUM['level2'] && $posts < $CONF_FORUM['level3']) {
            $user_level = sprintf($starimage, gf_getImage('rank2', 'ranks'), $CONF_FORUM['level2name'], $CONF_FORUM['level2name']);
            $user_levelname = $CONF_FORUM['level2name'];
        } elseif ($posts >= $CONF_FORUM['level3'] && $posts < $CONF_FORUM['level4']) {
            $user_level = sprintf($starimage, gf_getImage('rank3', 'ranks'), $CONF_FORUM['level3name'], $CONF_FORUM['level3name']);
            $user_levelname = $CONF_FORUM['level3name'];
        } elseif ($posts >= $CONF_FORUM['level4'] && $posts < $CONF_FORUM['level5']) {
            $user_level = sprintf($starimage, gf_getImage('rank4', 'ranks'), $CONF_FORUM['level4name'], $CONF_FORUM['level4name']);
            $user_levelname = $CONF_FORUM['level4name'];
        } elseif ($posts > $CONF_FORUM['level5']) {
            $user_level = sprintf($starimage, gf_getImage('rank5', 'ranks'), $CONF_FORUM['level5name'], $CONF_FORUM['level5name']);
            $user_levelname = $CONF_FORUM['level5name'];
        }
        if (forum_modPermission($showtopic['forum'], $showtopic['uid'])) {
            $user_level = sprintf($starimage, gf_getImage('rank_mod', 'ranks'), $LANG_GF01['moderator'], $LANG_GF01['moderator']);
            $user_levelname = $LANG_GF01['moderator'];
        }
        if (SEC_inGroup(1, $showtopic['uid'])) {
            $user_level = sprintf($starimage, gf_getImage('rank_admin', 'ranks'), $LANG_GF01['admin'], $LANG_GF01['admin']);
            $user_levelname = $LANG_GF01['admin'];
        }
        if ($userarray['photo'] != "") {
            $avatar = USER_getPhoto($showtopic['uid'], '', '', $CONF_FORUM['avatar_width']);
            $min_height = $min_height + 50;
        }
        $regdate = $LANG_GF01['REGISTERED'] . ': ' . strftime('%m/%d/%y', strtotime($userarray['regdate'])) . '<br>';
        $numposts = $LANG_GF01['POSTS'] . ': ' . $posts;
        if (DB_count($_TABLES['sessions'], 'uid', $showtopic['uid']) > 0 and DB_getItem($_TABLES['userprefs'], 'showonline', "uid={$showtopic['uid']}") == 1) {
            $avatar .= '<br>' . $LANG_GF01['STATUS'] . ' ' . $LANG_GF01['ONLINE'];
        } else {
            $avatar .= '<br>' . $LANG_GF01['STATUS'] . ' ' . $LANG_GF01['OFFLINE'];
        }
        if ($userarray['sig'] != '') {
            $sig = '<hr width="95%" size="1" style="color=:black; text-align:left; margin-left:0; margin-bottom:5;padding:0" noshade>';
            $sig .= '<B>' . $userarray['sig'] . '</B>';
            $min_height = $min_height + 30;
        }
    } else {
        $uservalid = false;
        $userlink = '<b>' . $showtopic['name'] . '</b>';
        $userlink = '<font size="-2">' . $LANG_GF01['ANON'] . '</font>' . $showtopic['name'];
    }
    if ($CONF_FORUM['show_moods'] && $showtopic['mood'] != "") {
        $moodimage = '<img align="absmiddle" src="' . gf_getImage($showtopic['mood'], 'moods') . '" title="' . $showtopic['mood'] . '"><br>';
        $min_height = $min_height + 30;
    }
    //$intervalTime = $mytimer->stopTimer();
    //COM_errorLog("Show Topic Display Time3: $intervalTime");
    // Handle Pre ver 2.5 quoting and New Line Formatting - consider adding this to a migrate function
    if ($CONF_FORUM['pre2.5_mode']) {
        // try to determine if we have an old post...
        if (strstr($showtopic['comment'], '<pre class="forumCode">') !== false) {
            $oldPost = 1;
        }
        if (strstr($showtopic['comment'], "[code]<code>") !== false) {
            $oldPost = 1;
        }
        if (strstr($showtopic['comment'], "<pre>") !== false) {
            $oldPost = 1;
        }
        if (stristr($showtopic['comment'], '[code') == false || stristr($showtopic['comment'], '[code]<code>') == true) {
            if (strstr($showtopic['comment'], "<pre>") !== false) {
                $oldPost = 1;
            }
            $showtopic['comment'] = str_replace('<pre>', '[code]', $showtopic['comment']);
            $showtopic['comment'] = str_replace('</pre>', '[/code]', $showtopic['comment']);
        }
        $showtopic['comment'] = str_ireplace("[code]<code>", '[code]', $showtopic['comment']);
        $showtopic['comment'] = str_ireplace("</code>[/code]", '[/code]', $showtopic['comment']);
        $showtopic['comment'] = str_replace(array("<br />\r\n", "<br />\n\r", "<br />\r", "<br />\n"), '<br />', $showtopic['comment']);
        $showtopic['comment'] = preg_replace("/\\[QUOTE\\sBY=\\s(.+?)\\]/i", "[QUOTE] Quote by \$1:", $showtopic['comment']);
        /* Reformat code blocks - version 2.3.3 and prior */
        $showtopic['comment'] = str_replace('<pre class="forumCode">', '[code]', $showtopic['comment']);
        $showtopic['comment'] = preg_replace("/\\[QUOTE\\sBY=(.+?)\\]/i", "[QUOTE] Quote by \$1:", $showtopic['comment']);
        if ($oldPost) {
            if (strstr($showtopic['comment'], "\\'") !== false) {
                $showtopic['comment'] = stripslashes($showtopic['comment']);
            }
        }
    }
    // Check and see if there are now no [file] bbcode tags in content and reset the show_inline value
    // This is needed in case user had used the file bbcode tag and then removed it
    if ($mode == 'preview' and strpos($showtopic['comment'], '[file]') === false) {
        $usql = "UPDATE {$_TABLES['gf_attachments']} SET show_inline = 0 ";
        if (isset($_POST['uniqueid']) and $_POST['uniqueid'] > 0) {
            // User is previewing a new post
            $usql .= "WHERE topic_id = {$_POST['uniqueid']} AND tempfile=1 ";
        } else {
            if (isset($showtopic['id'])) {
                $usql .= "WHERE topic_id = {$showtopic['id']} ";
            }
        }
        DB_query($usql);
    }
    $showtopic['comment'] = gf_formatTextBlock($showtopic['comment'], $showtopic['postmode'], $mode);
    $showtopic['subject'] = gf_formatTextBlock($showtopic['subject'], 'text', $mode);
    if (strlen($showtopic['subject']) > $CONF_FORUM['show_subject_length']) {
        $showtopic['subject'] = substr("{$showtopic['subject']}", 0, $CONF_FORUM['show_subject_length']);
        $showtopic['subject'] .= "...";
    }
    //$intervalTime = $mytimer->stopTimer();
    //COM_errorLog("Show Topic Display Time2: $intervalTime");
    if ($mode != 'preview' && $uservalid && $_USER['uid'] > 1 && $_USER['uid'] == $showtopic['uid']) {
        /* Check if user can still edit this post - within allowed edit timeframe */
        $editAllowed = false;
        if ($CONF_FORUM['allowed_editwindow'] > 0) {
            $t1 = $showtopic['date'];
            $t2 = $CONF_FORUM['allowed_editwindow'];
            if (time() - $t2 < $t1) {
                $editAllowed = true;
            }
        } else {
            $editAllowed = true;
        }
        if ($editAllowed) {
            $editlink = "{$_CONF['site_url']}/forum/createtopic.php?method=edit&forum={$showtopic['forum']}&id={$showtopic['id']}&editid={$showtopic['id']}&amp;page={$page}";
            $editlinkimg = '<img src="' . gf_getImage('edit_button') . '" border="0" align="absmiddle" alt="' . $LANG_GF01['EDITICON'] . '" TITLE="' . $LANG_GF01['EDITICON'] . '">';
            $topictemplate->set_var('editlink', $editlink);
            $topictemplate->set_var('editlinkimg', $editlinkimg);
            $topictemplate->set_var('LANG_edit', $LANG_GF01['EDITICON']);
            $topictemplate->parse('edittopic_link', 'edit');
        }
    }
    if ($highlight != '') {
        $showtopic['subject'] = str_replace("{$highlight}", "<font class=highlight>{$highlight}</font>", $showtopic['subject']);
        $showtopic['comment'] = str_replace("{$highlight}", "<font class=highlight>{$highlight}</font>", $showtopic['comment']);
    }
    if ($showtopic['pid'] == 0) {
        $replytopicid = $showtopic['id'];
        $is_lockedtopic = $showtopic['locked'];
        $views = $showtopic['views'];
        $topictemplate->set_var('read_msg', sprintf($LANG_GF02['msg49'], $views));
        if ($is_lockedtopic) {
            $topictemplate->set_var('locked_icon', '<img src="' . gf_getImage('padlock') . '" TITLE="' . $LANG_GF02['msg114'] . '">');
        }
    } else {
        $replytopicid = $showtopic['pid'];
        $is_lockedtopic = DB_getItem($_TABLES['gf_topic'], 'locked', "id={$showtopic['pid']}");
        $topictemplate->set_var('read_msg', '');
    }
    // Bookmark feature
    if ($_USER['uid'] > 1) {
        if (DB_count($_TABLES['gf_bookmarks'], array('uid', 'topic_id'), array($_USER['uid'], $showtopic['id']))) {
            $topictemplate->set_var('bookmark_icon', '<img src="' . gf_getImage('star_on_sm') . '" TITLE="' . $LANG_GF02['msg204'] . '">');
        } else {
            $topictemplate->set_var('bookmark_icon', '<img src="' . gf_getImage('star_off_sm') . '" TITLE="' . $LANG_GF02['msg203'] . '">');
        }
    }
    if ($CONF_FORUM['allow_user_dateformat']) {
        $date = COM_getUserDateTimeFormat($showtopic['date']);
        $topictemplate->set_var('posted_date', $date[0]);
    } else {
        $date = strftime($CONF_FORUM['default_Topic_Datetime_format'], $showtopic['date']);
        $topictemplate->set_var('posted_date', $date);
    }
    if ($mode != 'preview') {
        if ($is_lockedtopic == 0) {
            $is_readonly = DB_getItem($_TABLES['gf_forums'], 'is_readonly', 'forum_id=' . $showtopic['forum']);
            if ($is_readonly == 0 or forum_modPermission($showtopic['forum'], $_USER['uid'], 'mod_edit')) {
                $quotelink = "{$_CONF['site_url']}/forum/createtopic.php?method=postreply&forum={$showtopic['forum']}&id={$replytopicid}&quoteid={$showtopic['id']}";
                $quotelinkimg = '<img src="' . gf_getImage('quote_button') . '" border="0" align="absmiddle" alt="' . $LANG_GF01['QUOTEICON'] . '" TITLE="' . $LANG_GF01['QUOTEICON'] . '">';
                $topictemplate->set_var('quotelink', $quotelink);
                $topictemplate->set_var('quotelinkimg', $quotelinkimg);
                $topictemplate->set_var('LANG_quote', $LANG_GF01['QUOTEICON']);
                $topictemplate->parse('quotetopic_link', 'quote');
            }
        }
        //$topictemplate->set_var ('topic_post_link_begin', '<a name="'.$showtopic['id'].'">');
        //$topictemplate->set_var ('topic_post_link_end', '</a>');
        $mod_functions = forum_getmodFunctions($showtopic);
        if ($showtopic['uid'] > 1 && $uservalid) {
            $profile_link = "{$_CONF['site_url']}/users.php?mode=profile&uid={$showtopic['uid']}";
            $profile_linkimg = '<img src="' . gf_getImage('profile_button') . '" border="0" align="absmiddle" alt="' . $LANG_GF01['ProfileLink'] . '" TITLE="' . $LANG_GF01['ProfileLink'] . '">';
            $topictemplate->set_var('profilelink', $profile_link);
            $topictemplate->set_var('profilelinkimg', $profile_linkimg);
            $topictemplate->set_var('LANG_profile', $LANG_GF01['ProfileLink']);
            $topictemplate->parse('profile_link', 'profile');
            if ($CONF_FORUM['use_pm_plugin']) {
                $pmusernmame = COM_getDisplayName($showtopic['uid']);
                $pmplugin_link = forumPLG_getPMlink($pmusernmame);
                if ($pmplugin_link != '') {
                    $pm_link = $pmplugin_link;
                    $pm_linkimg = '<img src="' . gf_getImage('pm_button') . '" border="0" align="absmiddle" alt="' . $LANG_GF01['PMLink'] . '" TITLE="' . $LANG_GF01['PMLink'] . '">';
                    $topictemplate->set_var('pmlink', $pm_link);
                    $topictemplate->set_var('pmlinkimg', $pm_linkimg);
                    $topictemplate->set_var('LANG_pm', $LANG_GF01['PMLink']);
                    $topictemplate->parse('pm_link', 'pm');
                }
            }
        }
        if ($userarray['email'] != '' && $showtopic["uid"] > 1) {
            $email_link = "{$_CONF['site_url']}/profiles.php?uid={$showtopic['uid']}";
            $email_linkimg = '<img src="' . gf_getImage('email_button') . '" border="0" align="absmiddle" alt="' . $LANG_GF01['EmailLink'] . '" TITLE="' . $LANG_GF01['EmailLink'] . '">';
            $topictemplate->set_var('emaillink', $email_link);
            $topictemplate->set_var('emaillinkimg', $email_linkimg);
            $topictemplate->set_var('LANG_email', $LANG_GF01['EmailLink']);
            $topictemplate->parse('email_link', 'email');
        }
        if ($userarray['homepage'] != '') {
            $homepage = $userarray['homepage'];
            if (!eregi("http", $homepage)) {
                $homepage = 'http://' . $homepage;
            }
            $homepageimg = '<img src="' . gf_getImage('website_button') . '" border="0" align="absmiddle" alt="' . $LANG_GF01['WebsiteLink'] . '" TITLE="' . $LANG_GF01['WebsiteLink'] . '">';
            $topictemplate->set_var('websitelink', $homepage);
            $topictemplate->set_var('websitelinkimg', $homepageimg);
            $topictemplate->set_var('LANG_website', $LANG_GF01['WebsiteLink']);
            $topictemplate->parse('website_link', 'website');
        }
        if ($fromblock != "") {
            $back2 = $LANG_GF01['back2parent'];
        } else {
            $back2 = $LANG_GF01['back2top'];
        }
        $backlink = '<center><a href="' . $_CONF['site_url'] . '/forum/viewtopic.php?showtopic=' . $replytopicid . '">' . $back2 . '</a></center>';
    } else {
        if ($_GET['onlytopic'] != 1) {
            $topictemplate->set_var('posted_date', '');
            $topictemplate->set_var('preview_topic_subject', $showtopic['subject']);
        } else {
            $topictemplate->set_var('preview_topic_subject', '');
        }
        $topictemplate->set_var('read_msg', '');
        $topictemplate->set_var('locked_icon', '');
        $topictemplate->set_var('preview_mode', 'none');
        // Check and see if there are no [file] bbcode tags in content and reset the show_inline value
        // This is needed in case user had used the file bbcode tag and then removed it
        $imagerecs = '';
        if (is_array($forumfiles)) {
            $imagerecs = implode(',', $forumfiles);
        }
        if (!empty($_POST['uniqueid'])) {
            $sql = "UPDATE {$_TABLES['gf_attachments']} SET show_inline = 0 WHERE topic_id={$_POST['uniqueid']} ";
            if ($imagerecs != '') {
                $sql .= "AND id NOT IN ({$imagerecs})";
            }
            DB_query($sql);
        } else {
            if (isset($_POST['id'])) {
                $sql = "UPDATE {$_TABLES['gf_attachments']} SET show_inline = 0 WHERE topic_id={$_POST['id']} ";
                if ($imagerecs != '') {
                    $sql .= "AND id NOT IN ({$imagerecs})";
                }
                DB_query($sql);
            }
        }
    }
    //$intervalTime = $mytimer->stopTimer();
    //COM_errorLog("Show Topic Display Time4: $intervalTime");
    $showtopic['comment'] = str_replace('{', '&#123;', $showtopic['comment']);
    $showtopic['comment'] = str_replace('}', '&#125;', $showtopic['comment']);
    $uniqueid = COM_applyFilter($_POST['uniqueid'], true);
    if ($showtopic['id'] > 0) {
        $topictemplate->set_var('attachments', gf_showattachments($showtopic['id']));
    } elseif ($uniqueid > 0) {
        $topictemplate->set_var('attachments', gf_showattachments($uniqueid));
    }
    $topictemplate->set_var('layout_url', $_CONF['layout_url']);
    $topictemplate->set_var('csscode', $onetwo);
    $topictemplate->set_var('postmode', $showtopic['postmode']);
    $topictemplate->set_var('userlink', $userlink);
    $topictemplate->set_var('lang_forum', $LANG_GF01['FORUM']);
    $topictemplate->set_var('user_levelname', $user_levelname);
    $topictemplate->set_var('user_level', $user_level);
    $topictemplate->set_var('magical_image', $moodimage);
    $topictemplate->set_var('avatar', $avatar);
    $topictemplate->set_var('regdate', $regdate);
    $topictemplate->set_var('numposts', $numposts);
    $topictemplate->set_var('location', $location);
    $topictemplate->set_var('site_url', $_CONF['site_url']);
    $topictemplate->set_var('imgset', $CONF_FORUM['imgset']);
    $topictemplate->set_var('topic_subject', $showtopic['subject']);
    $topictemplate->set_var('LANG_ON2', $LANG_GF01['ON2']);
    $topictemplate->set_var('mod_functions', $mod_functions);
    $topictemplate->set_var('topic_comment', $showtopic['comment']);
    $topictemplate->set_var('comment_minheight', "min-height:{$min_height}px");
    if (trim($sig) != '') {
        $topictemplate->set_var('sig', PLG_replaceTags($sig));
        $topictemplate->set_var('show_sig', '');
    } else {
        $topictemplate->set_var('sig', '');
        $topictemplate->set_var('show_sig', 'none');
    }
    $topictemplate->set_var('forumid', $showtopic['forum']);
    $topictemplate->set_var('topic_id', $showtopic['id']);
    $topictemplate->set_var('back_link', $backlink);
    $topictemplate->set_var('member_badge', forumPLG_getMemberBadge($showtopic['uid']));
    $topictemplate->parse('output', 'topictemplate');
    $retval .= $topictemplate->finish($topictemplate->get_var('output'));
    //$intervalTime = $mytimer->stopTimer();
    //COM_errorLog("Show Topic Display Time5: $intervalTime");
    return $retval;
}
Example #21
0
}
$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;
Example #22
0
/**
* This will email new stories in the topics that the user is interested in
*
* In account information the user can specify which topics for which they
* will receive any new article for in a daily digest.
*
* @return   void
*/
function COM_emailUserTopics()
{
    global $_CONF, $_TABLES, $LANG04, $LANG08, $LANG24;
    if ($_CONF['emailstories'] == 0) {
        return;
    }
    $subject = strip_tags($_CONF['site_name'] . $LANG08[30] . strftime('%Y-%m-%d', time()));
    $authors = array();
    // Get users who want stories emailed to them
    $usersql = "SELECT username,email,etids,{$_TABLES['users']}.uid AS uuid " . "FROM {$_TABLES['users']}, {$_TABLES['userindex']} " . "WHERE {$_TABLES['users']}.uid > 1 AND {$_TABLES['userindex']}.uid = {$_TABLES['users']}.uid AND (etids <> '-' OR etids IS NULL) ORDER BY {$_TABLES['users']}.uid";
    $users = DB_query($usersql);
    $nrows = DB_numRows($users);
    $lastrun = DB_getItem($_TABLES['vars'], 'value', "name = 'lastemailedstories'");
    // For each user, pull the stories they want and email it to them
    for ($x = 0; $x < $nrows; $x++) {
        $U = DB_fetchArray($users);
        $storysql = array();
        $storysql['mysql'] = "SELECT sid,uid,date AS day,title,introtext,bodytext";
        $storysql['pgsql'] = "SELECT sid,uid,date AS day,title,introtext,postmode";
        $storysql['mssql'] = "SELECT sid,uid,date AS day,title,CAST(introtext AS text) AS introtext,CAST(bodytext AS text) AS introtext";
        $commonsql = " FROM {$_TABLES['stories']} WHERE draft_flag = 0 AND date <= NOW() AND date >= '{$lastrun}'";
        $topicsql = "SELECT tid FROM {$_TABLES['topics']}" . COM_getPermSQL('WHERE', $U['uuid']);
        $tresult = DB_query($topicsql);
        $trows = DB_numRows($tresult);
        if ($trows == 0) {
            // this user doesn't seem to have access to any topics ...
            continue;
        }
        $TIDS = array();
        for ($i = 0; $i < $trows; $i++) {
            $T = DB_fetchArray($tresult);
            $TIDS[] = $T['tid'];
        }
        if (!empty($U['etids'])) {
            $ETIDS = explode(' ', $U['etids']);
            $TIDS = array_intersect($TIDS, $ETIDS);
        }
        if (count($TIDS) > 0) {
            $commonsql .= " AND (tid IN ('" . implode("','", $TIDS) . "'))";
        }
        $commonsql .= COM_getPermSQL('AND', $U['uuid']);
        $commonsql .= ' ORDER BY featured DESC, date DESC';
        $storysql['mysql'] .= $commonsql;
        $storysql['mssql'] .= $commonsql;
        $storysql['pgsql'] .= $commonsql;
        $stories = DB_query($storysql);
        $nsrows = DB_numRows($stories);
        if ($nsrows == 0) {
            // If no new stories where pulled for this user, continue with next
            continue;
        }
        $mailtext = $LANG08[29] . strftime($_CONF['shortdate'], time()) . "\n";
        for ($y = 0; $y < $nsrows; $y++) {
            // Loop through stories building the requested email message
            $S = DB_fetchArray($stories);
            $mailtext .= "\n------------------------------\n\n";
            $mailtext .= "{$LANG08['31']}: " . COM_undoSpecialChars(stripslashes($S['title'])) . "\n";
            if ($_CONF['contributedbyline'] == 1) {
                if (empty($authors[$S['uid']])) {
                    $storyauthor = COM_getDisplayName($S['uid']);
                    $authors[$S['uid']] = $storyauthor;
                } else {
                    $storyauthor = $authors[$S['uid']];
                }
                $mailtext .= "{$LANG24['7']}: " . $storyauthor . "\n";
            }
            $mailtext .= "{$LANG08['32']}: " . strftime($_CONF['date'], strtotime($S['day'])) . "\n\n";
            if ($_CONF['emailstorieslength'] > 0) {
                if ($S['postmode'] === 'wikitext') {
                    $storytext = COM_undoSpecialChars(strip_tags(COM_renderWikiText(stripslashes($S['introtext']))));
                } else {
                    $storytext = COM_undoSpecialChars(strip_tags(PLG_replaceTags(stripslashes($S['introtext']))));
                }
                if ($_CONF['emailstorieslength'] > 1) {
                    $storytext = COM_truncate($storytext, $_CONF['emailstorieslength'], '...');
                }
                $mailtext .= $storytext . "\n\n";
            }
            $mailtext .= $LANG08[33] . ' ' . COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $S['sid']) . "\n";
        }
        $mailtext .= "\n------------------------------\n";
        $mailtext .= "\n{$LANG08['34']}\n";
        $mailtext .= "\n------------------------------\n";
        $mailto = $U['username'] . ' <' . $U['email'] . '>';
        if ($_CONF['site_mail'] !== $_CONF['noreply_mail']) {
            $mailfrom = $_CONF['noreply_mail'];
            $mailtext .= LB . LB . $LANG04[159];
        } else {
            $mailfrom = $_CONF['site_mail'];
        }
        COM_mail($mailto, $subject, $mailtext, $mailfrom);
    }
    DB_query("UPDATE {$_TABLES['vars']} SET value = NOW() WHERE name = 'lastemailedstories'");
}
Example #23
0
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 .= '&nbsp;<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 . '&amp;mode=upload">' . $LANG_MG01['add_media'] . '</a></li>';
        $showAdminMenu = 1;
    }
    if ($MG_albums[0]->owner_id) {
        $admin_menu .= '<li><a href="' . $admin_url . '&amp;mode=albumsort">' . $LANG_MG01['sort_albums'] . '</a></li>';
        $admin_menu .= '<li><a href="' . $admin_url . '&amp;mode=globalattr">' . $LANG_MG01['globalattr'] . '</a></li>' . LB;
        $admin_menu .= '<li><a href="' . $admin_url . '&amp;mode=globalperm">' . $LANG_MG01['globalperm'] . '</a></li>' . LB;
        $queue_count = DB_count($_TABLES['mg_media_album_queue']);
        $admin_menu .= '<li><a href="' . $admin_url . '&amp;mode=moderate">' . $LANG_MG01['media_queue'] . ' (' . $queue_count . ')</a></li>' . LB;
        $admin_menu .= '<li><a href="' . $admin_url . '&amp;mode=wmmanage">' . $LANG_MG01['wm_management'] . '</a></li>' . LB;
        $admin_menu .= '<li><a href="' . $admin_url . '&amp;mode=create">' . $LANG_MG01['create_album'] . '</a></li>' . LB;
        $showAdminMenu = 1;
    } elseif ($MG_albums[0]->access == 3) {
        $admin_Menu .= '<li><a href="' . $abmin_url . '&amp;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 . '&amp;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 . '&amp;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 . '&amp;page=1' . '">' . $MG_albums[$SAchild]->title . ' (' . $mediaCount . ')</a></li>';
                                }
                                $saRows++;
                            }
                        }
                    }
                    if ($_MG_CONF['subalbum_select'] == 1) {
                        $subAlbumDisplay .= '</optgroup></select>';
                        $subAlbumDisplay .= '&nbsp;<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 . '&amp;page=1' . '">', 'media_link_end' => '</a>', 'url_media_item' => $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$achild[$indexCounter]]->id . '&amp;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 . '&amp;page=1' . '">', 'media_link_end' => '</a>', 'url_media_item' => $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$achild[$indexCounter]]->id . '&amp;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;
}
Example #24
0
/**
 *  Display an ad's detail
 *  @param  string  $ad_id  ID of ad to display
 */
function adDetail($ad_id = '')
{
    global $_USER, $_TABLES, $_CONF, $LANG_ADVT, $_CONF_ADVT;
    USES_lib_comments();
    // Determind if this is an administrator
    $admin = SEC_hasRights($_CONF_ADVT['pi_name'] . '.admin');
    $ad_id = COM_sanitizeID($ad_id);
    if ($ad_id == '') {
        // An ad id is required for this function
        return CLASSIFIEDS_errorMsg($LANG_ADVT['missing_id'], 'alert');
    }
    $srchval = isset($_GET['query']) ? trim($_GET['query']) : '';
    // We use this in a few places here, so might as well just
    // figure it out once and save it.
    $perm_sql = COM_getPermSQL('AND', 0, 2, 'ad') . ' ' . COM_getPermSQL('AND', 0, 2, 'cat');
    // get the ad information.
    $sql = "SELECT ad.*\n            FROM {$_TABLES['ad_ads']} ad\n            LEFT JOIN {$_TABLES['ad_category']} cat\n                ON ad.cat_id = cat.cat_id\n            WHERE ad_id='{$ad_id}'";
    if (!$admin) {
        $sql .= $perm_sql;
    }
    $result = DB_query($sql);
    if (!$result || DB_numRows($result) < 1) {
        return CLASSIFIEDS_errorMsg($LANG_ADVT['no_ad_found'], 'note', 'Oops...');
    }
    $ad = DB_fetchArray($result, false);
    // Check access to the ad.  If granted, check that access isn't
    // blocked by any category.
    $my_access = CLASSIFIEDS_checkAccess($ad['ad_id'], $ad);
    if ($my_access >= 2) {
        $my_cat_access = CLASSIFIEDS_checkCatAccess($ad['cat_id'], false);
        if ($my_cat_access < $my_access) {
            $my_access = $my_cat_access;
        }
    }
    if ($my_access < 2) {
        return CLASSIFIEDS_errorMsg($LANG_ADVT['no_permission'], 'alert', $LANG_ADVT['access_denied']);
    }
    $cat = (int) $ad['cat_id'];
    // Increment the views counter
    $sql = "UPDATE {$_TABLES['ad_ads']} \n            SET views = views + 1 \n            WHERE ad_id='{$ad_id}'";
    DB_query($sql);
    // Get the previous and next ads
    $condition = " AND ad.cat_id={$cat}";
    if (!$admin) {
        $condition .= $perm_sql;
    }
    $sql = "SELECT ad_id\n            FROM {$_TABLES['ad_ads']} ad\n            LEFT JOIN {$_TABLES['ad_category']} cat\n                ON ad.cat_id = cat.cat_id\n            WHERE ad_id < '{$ad_id}' \n            {$condition}\n            ORDER BY ad_id DESC\n            LIMIT 1";
    $r = DB_query($sql);
    list($preAd_id) = DB_fetchArray($r, false);
    $sql = "SELECT ad_id\n            FROM {$_TABLES['ad_ads']} ad\n            LEFT JOIN {$_TABLES['ad_category']} cat\n                ON ad.cat_id = cat.cat_id\n            WHERE ad_id > '{$ad_id}' \n            {$condition}\n            ORDER BY ad_id ASC\n            LIMIT 1";
    $r = DB_query($sql);
    list($nextAd_id) = DB_fetchArray($r, false);
    // Get the user contact info. If none, just show the email link
    $sql = "SELECT * \n            FROM {$_TABLES['ad_uinfo']} \n            WHERE uid='{$ad['uid']}'";
    //echo $sql;
    $result = DB_query($sql);
    $uinfo = array();
    if ($result && DB_numRows($result) > 0) {
        $uinfo = DB_fetchArray($result);
    } else {
        $uinfo['uid'] = '';
        $uinfo['address'] = '';
        $uinfo['city'] = '';
        $uinfo['state'] = '';
        $uinfo['postal'] = '';
        $uinfo['tel'] = '';
        $uinfo['fax'] = '';
    }
    // Get the hot results (most viewed ads)
    $time = time();
    $sql = "SELECT ad.ad_id, ad.cat_id, ad.subject,\n                    cat.cat_id, cat.fgcolor, cat.bgcolor\n        FROM {$_TABLES['ad_ads']} ad\n        LEFT JOIN {$_TABLES['ad_category']} cat\n            ON ad.cat_id = cat.cat_id\n        WHERE ad.exp_date > {$time} \n            {$perm_sql}\n        ORDER BY views DESC \n        LIMIT 4";
    //echo $sql;die;
    $hotresult = DB_query($sql);
    // convert line breaks & others to html
    $patterns = array('/\\n/');
    $replacements = array('<br />');
    $ad['descript'] = PLG_replaceTags(COM_checkHTML($ad['descript']));
    $ad['descript'] = preg_replace($patterns, $replacements, $ad['descript']);
    $ad['subject'] = strip_tags($ad['subject']);
    $ad['price'] = strip_tags($ad['price']);
    $ad['url'] = COM_sanitizeUrl($ad['url']);
    $ad['keywords'] = strip_tags($ad['keywords']);
    // Highlight search terms, if any
    if ($srchval != '') {
        $ad['subject'] = COM_highlightQuery($ad['subject'], $srchval);
        $ad['descript'] = COM_highlightQuery($ad['descript'], $srchval);
    }
    $detail = new Template(CLASSIFIEDS_PI_PATH . '/templates');
    $detail->set_file('detail', 'detail.thtml');
    if ($admin) {
        $base_url = CLASSIFIEDS_ADMIN_URL . '/index.php';
        $del_link = $base_url . '?delete=ad&ad_id=' . $ad_id;
        $edit_link = $base_url . '?edit=ad&ad_id=' . $ad_id;
    } else {
        $base_url = CLASSIFIEDS_URL . '/index.php';
        $del_link = $base_url . '?mode=Delete&id=' . $ad_id;
        $edit_link = $base_url . '?mode=editad&id=' . $ad_id;
    }
    // Set up the "add days" form if this user is the owner
    // or an admin
    if ($my_access == 3) {
        // How many days has the ad run?
        $max_add_days = CLASSIFIEDS_calcMaxAddDays(($ad['exp_date'] - $ad['add_date']) / 86400);
        if ($max_add_days > 0) {
            $detail->set_var('max_add_days', $max_add_days);
        }
    }
    if ($ad['exp_date'] < $time) {
        $detail->set_var('is_expired', 'true');
    }
    USES_classifieds_class_category();
    $detail->set_var(array('base_url' => $base_url, 'edit_link' => $edit_link, 'del_link' => $del_link, 'curr_loc' => adCategory::BreadCrumbs($cat, true), 'subject' => $ad['subject'], 'add_date' => date($_CONF['shortdate'], $ad['add_date']), 'exp_date' => date($_CONF['shortdate'], $ad['exp_date']), 'views_no' => $ad['views'], 'descript' => $ad['descript'], 'ad_type' => CLASSIFIEDS_getAdTypeString($ad['ad_type']), 'uinfo_address' => $uinfo['address'], 'uinfo_city' => $uinfo['city'], 'uinfo_state' => $uinfo['state'], 'uinfo_postcode' => $uinfo['postcode'], 'uinfo_tel' => $uinfo['tel'], 'uinfo_fax' => $uinfo['fax'], 'price' => $ad['price'], 'ad_id' => $ad_id, 'ad_url' => $ad['url'], 'username' => $_CONF_ADVT['disp_fullname'] == 1 ? COM_getDisplayName($ad['uid']) : DB_getItem($_TABLES['users'], 'username', "uid={$ad['uid']}"), 'fgcolor' => $ad['fgcolor'], 'bgcolor' => $ad['bgcolor'], 'cat_id' => $ad['cat_id']));
    // Display a link to email the poster, or other message as needed
    $emailfromuser = DB_getItem($_TABLES['userprefs'], 'emailfromuser', "uid={$ad['uid']}");
    if ($_CONF['emailuserloginrequired'] == 1 && COM_isAnonUser() || $emailfromuser < 1) {
        $detail->set_var('ad_uid', '');
    } else {
        $detail->set_var('ad_uid', $ad['uid']);
    }
    if ($my_access == 3) {
        $detail->set_var('have_userlinks', 'true');
        if ($admin || $_CONF_ADVT['usercanedit'] == 1) {
            $detail->set_var('have_editlink', 'true');
        } else {
            $detail->set_var('have_editlink', '');
        }
    } else {
        $detail->set_var('have_userlinks', '');
    }
    // Retrieve the photos and put into the template
    $sql = "SELECT photo_id, filename\n            FROM {$_TABLES['ad_photo']} \n            WHERE ad_id='{$ad_id}'";
    $photo = DB_query($sql);
    $photo_detail = '';
    $detail->set_var('have_photo', '');
    // assume no photo available
    if ($photo && DB_numRows($photo) >= 1) {
        while ($prow = DB_fetchArray($photo)) {
            $img_small = LGLIB_ImageUrl(CLASSIFIEDS_IMGPATH . '/' . $prow['filename'], $_CONF_ADVT['detail_img_width']);
            $img_disp = CLASSIFIEDS_dispUrl($prow['filename']);
            if (!empty($img_small)) {
                $detail->set_block('detail', 'PhotoBlock', 'PBlock');
                $detail->set_var(array('tn_width' => $_CONF_ADVT['detail_img_width'], 'small_url' => $img_small, 'disp_url' => $img_disp));
                $detail->parse('PBlock', 'PhotoBlock', true);
                $detail->set_var('have_photo', 'true');
            }
        }
    }
    if (DB_count($_TABLES['ad_ads'], 'owner_id', (int) $ad['owner_id']) > 1) {
        $detail->set_var('byposter_url', CLASSIFIEDS_URL . '/index.php?' . "page=byposter&uid={$ad['owner_id']}");
    }
    // Show previous and next ads
    if ($preAd_id != '') {
        $detail->set_var('previous', '<a href="' . CLASSIFIEDS_makeURL('detail', $preAd_id) . "\">&lt;&lt;</a>");
    }
    if ($nextAd_id != '') {
        $detail->set_var('next', '<a href="' . CLASSIFIEDS_makeURL('detail', $nextAd_id) . "\">  &gt;&gt;</a>");
    }
    // Show the "hot results"
    $hot_data = '';
    if ($hotresult) {
        $detail->set_block('detail', 'HotBlock', 'HBlock');
        while ($hotrow = DB_fetchArray($hotresult)) {
            $detail->set_var(array('hot_title' => $hotrow['subject'], 'hot_url' => CLASSIFIEDS_makeURL('detail', $hotrow['ad_id']), 'hot_cat' => displayCat($hotrow['cat_id'])));
            /*$hot_data .= "<tr><td class=\"hottitle\"><a href=\"" .
                            CLASSIFIEDS_makeURL('detail', $hotrow['ad_id']) .
                            "\">{$hotrow['subject']}</a></small></td>\n";
            
                        $hot_data .= "<td class=\"hotcat\">( " . displayCat($hotrow['cat_id']) . 
                                    " )</td></tr>\n";*/
        }
        $detail->parse('HBlock', 'HotBlock', true);
    }
    $detail->set_var('whats_hot_row', $hot_data);
    // Show the user comments
    if (plugin_commentsupport_classifieds() && $ad['comments_enabled'] < 2) {
        $detail->set_var('usercomments', CMT_userComments($ad_id, $ad['subject'], 'classifieds', '', '', 0, 1, false, false, $ad['comments_enabled']));
        //$detail->set_var('usercomments', CMT_userComments($ad_id, $subject,
        //        'classifieds'));
    }
    $detail->parse('output', 'detail');
    $display = $detail->finish($detail->get_var('output'));
    return $display;
}
Example #25
0
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&amp;s=1&amp;album_id=' . $M['album_id'] . '&amp;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' . '&amp;sort=' . $sortOrder . '&amp;s=' . $M['media_id'] . '&amp;i=' . $id . '&amp;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&amp;s=1&amp;album_id=' . $M['album_id'] . '&amp;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' . '&amp;sort=' . $sortOrder . '&amp;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;
}
Example #26
0
File: index.php Project: ivywe/maps
function MAPS_displayFrontPage()
{
    global $_CONF, $_MAPS_CONF, $LANG_MAPS_1, $_TABLES;
    $retval = '';
    if ($_MAPS_CONF['map_main_header'] != '') {
        $header = '<div>' . PLG_replaceTags($_MAPS_CONF['map_main_header']) . '</div>';
    } else {
        $header1 = '<p style="margin-top:25px;">' . $LANG_MAPS_1['user_maps_list'] . '</p>';
    }
    // Get maps from database
    $sql = "SELECT mid, name, description, active, hidden, modified, hits FROM {$_TABLES['maps_maps']} ORDER BY name ASC";
    $res = DB_query($sql);
    // Create maps list template
    $map = new Template($_CONF['path'] . 'plugins/maps/templates');
    $map->set_file(array('map' => 'list_map_item.thtml', 'start' => 'list_map_start.thtml', 'end' => 'list_map_end.thtml'));
    // Display the begging of the map list
    $retval .= $map->parse('output', 'start');
    $list = 0;
    $lastmod = array();
    $markerssum = 0;
    while ($A = DB_fetchArray($res)) {
        if ($A['active'] == 1 && $A['hidden'] == 0) {
            $map->set_var('mid', $A['mid']);
            $map->set_var('name', stripslashes($A['name']));
            $map->set_var('xhtml', XHTML);
            $name = urlencode($A['name']);
            $map->set_var('map_detail', $_MAPS_CONF['site_url'] . '/index.php?mode=map&amp;mid=' . $A['mid'] . '&name=' . $name . '&amp;query_limit=500');
            if ($A['description'] != '') {
                $map->set_var('description', '<br' . XHTML . '>' . stripslashes($A['description']));
            } else {
                $map->set_var('description', '');
            }
            //See map and markers
            if (function_exists('MAPS_getFields')) {
                $map->set_var('view_map', '<a href="' . $_MAPS_CONF['site_url'] . '/index.php?mode=map&amp;mid=' . $A['mid'] . '&name=' . $name . '&amp;query_limit=500">' . $LANG_MAPS_1['view_map'] . '</a> | ');
                $map->set_var('view_markers', '<a href="' . $_MAPS_CONF['site_url'] . '/index.php?mode=markers&amp;mid=' . $A['mid'] . '&name=' . $name . '">' . $LANG_MAPS_1['view_markers'] . ' | </a>');
            } else {
                $map->set_var('view_map', '');
                $map->set_var('view_markers', '');
            }
            //update
            $currentmod = COM_getUserDateTimeFormat($A['modified']);
            if ($currentmod[1] > $lastmod[1]) {
                $lastmod = COM_getUserDateTimeFormat($A['modified']);
            }
            $update = COM_getUserDateTimeFormat($A['modified']);
            $map->set_var('update', $LANG_MAPS_1['last_modification'] . ' ' . $update[0]);
            //markers
            $markers = DB_count($_TABLES['maps_markers'], 'mid', $A['mid']);
            $markerssum = $markerssum + $markers;
            $map->set_var('markers', ' | ' . $markers . ' ' . $LANG_MAPS_1['records']);
            //hits
            $map->set_var('hits', ' | ' . $A['hits'] . ' ' . $LANG_MAPS_1['hits']);
            if (SEC_hasRights('maps.admin')) {
                $map->set_var('edit_button', '<form id="edit_map" action="' . $_CONF['site_admin_url'] . '/plugins/maps/map_edit.php" method="POST">
	        <div style="float:right">
	          <input type="image" src="' . $_CONF['site_admin_url'] . '/plugins/maps/images/edit.png" align="absmiddle" />
			  <input type="hidden" name="mode" value="edit" />
			   <input type="hidden" name="mid" value="' . $A['mid'] . '" />
	        </div>
	        </form>');
            } else {
                $map->set_var('edit_button', '');
            }
            $retval .= $map->parse('output', 'map');
            $list++;
        }
    }
    if ($list == 0 && $_MAPS_CONF['global_map'] == 0 && $_MAPS_CONF['users_map'] == 1) {
        $retval .= '<p>' . $LANG_MAPS_1['no_map_user'] . '</p>';
        if (SEC_hasRights('maps.admin')) {
            $retval .= '<p>' . $LANG_MAPS_1['admin_can'] . '<a href="' . $_CONF['site_admin_url'] . '/plugins/maps/map_edit.php?mode=new"> ' . $LANG_MAPS_1['create_map'] . '</a>.</p>';
        }
    } else {
        if ($_MAPS_CONF['global_map'] == 1 && $list > 1) {
            //global map
            $map->set_var('edit_button', '');
            $map->set_var('xhtml', XHTML);
            $map->set_var('name', $LANG_MAPS_1['global_map']);
            $map->set_var('map_detail', $_MAPS_CONF['site_url'] . '/index.php?mode=map&amp;mid=0&name=' . urlencode($LANG_MAPS_1['global_map']) . '&amp;query_limit=500');
            $map->set_var('description', '<br' . XHTML . '>' . $LANG_MAPS_1['info_global_map']);
            if (function_exists('MAPS_getFields')) {
                $map->set_var('view_map', '<a href="' . $_MAPS_CONF['site_url'] . '/index.php?mode=map&amp;mid=0&name=' . urlencode($LANG_MAPS_1['global_map']) . '&amp;query_limit=500">' . $LANG_MAPS_1['view_map'] . '</a> | ');
                $map->set_var('view_markers', '<a href="' . $_MAPS_CONF['site_url'] . '/index.php?mode=markers&amp;mid=0&name=' . urlencode($LANG_MAPS_1['global_map']) . '">' . $LANG_MAPS_1['view_markers'] . ' | </a>');
            } else {
                $map->set_var('view_map', '');
                $map->set_var('view_markers', '');
            }
            //update
            $updateglobal = COM_getUserDateTimeFormat(time());
            $map->set_var('update', $LANG_MAPS_1['last_modification'] . ' ' . $updateglobal[0]);
            //markers
            $markers = DB_count($_TABLES['maps_markers'], 'mid', $A['mid']);
            $map->set_var('markers', ' | ' . $markerssum . ' ' . $LANG_MAPS_1['records']);
            //hits
            $map->set_var('hits', ' | ' . DB_getItem($_TABLES['vars'], 'value', "name='globalMapHits'") . ' ' . $LANG_MAPS_1['hits']);
            $retval .= $map->parse('output', 'map');
        }
        if ($_MAPS_CONF['users_map'] == 1) {
            $retval .= '<p class="maps_list_item"><strong><a href="' . $_MAPS_CONF['site_url'] . '/users_map.php">' . $LANG_MAPS_1['users_map'] . '</a></strong><br' . XHTML . '>' . $LANG_MAPS_1['info_users_map'] . '</p>';
        }
        if (SEC_hasRights('maps.admin')) {
            $retval .= '&nbsp;<p>' . $LANG_MAPS_1['admin_can'] . ' <a href="' . $_CONF['site_admin_url'] . '/plugins/maps/map_edit.php?mode=new">' . $LANG_MAPS_1['create_map'] . '</a></p>';
        }
    }
    // Display the end of the maps list
    $retval .= $map->parse('output', 'end');
    //Display global map if active
    if (COM_isAnonUser() && $_MAPS_CONF['maps_login_required'] == 1) {
        // do not display global map
        $retval = $header1 . $retval;
    } else {
        if ($_MAPS_CONF['global_map'] == 1 && $list > 0) {
            $retval = MAPS_getGlobalMap('', '', true) . $header1 . $retval;
        } else {
            $retval = $header1 . $retval;
        }
    }
    $footer = '<div>' . PLG_replaceTags($_MAPS_CONF['map_main_footer']) . '</div>';
    return $header . $retval . $footer;
}
Example #27
0
 /**
  * Returns text ready for the edit fields.
  *
  * @access Private
  * @param   string  $in Text to prepare for editing
  * @return  string  Escaped String
  */
 function _editText($in)
 {
     $out = '';
     //        $out = $this->replaceImages($in);
     // Remove any autotags the user doesn't have permission to use
     $out = PLG_replaceTags($in, '', true);
     if ($this->_postmode == 'plaintext') {
         $out = COM_undoClickableLinks($out);
         $out = $this->_displayEscape($out);
     } elseif ($this->_postmode == 'wikitext') {
         $out = $this->_editUnescape($in);
     } else {
         // html
         $out = str_replace('<pre><code>', '[code]', $out);
         $out = str_replace('</code></pre>', '[/code]', $out);
         $out = str_replace('<!--raw--><span class="raw">', '[raw]', $out);
         $out = str_replace('</span><!--/raw-->', '[/raw]', $out);
         $out = $this->_editUnescape($out);
         $out = $this->_displayEscape(htmlspecialchars($out));
     }
     return $out;
 }
Example #28
0
 function albumThumbnail()
 {
     global $_CONF, $_MG_CONF, $_MG_USERPREFS, $_TABLES, $_USER, $LANG_MG00, $LANG_MG01, $LANG_MG03, $MG_albums;
     if ($this->media_count > 0) {
         if ($this->cover_filename != '' && $this->cover_filename != '0') {
             $media_size = false;
             foreach ($_MG_CONF['validExtensions'] as $ext) {
                 if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $this->cover_filename[0] . '/' . $this->cover_filename . $ext)) {
                     $album_last_image = $_MG_CONF['mediaobjects_url'] . '/tn/' . $this->cover_filename[0] . '/' . $this->cover_filename . $ext;
                     $mediasize = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $this->cover_filename[0] . '/' . $this->cover_filename . $ext);
                     break;
                 }
             }
             $album_last_update = MG_getUserDateTimeFormat($this->last_update);
             if ($mediasize == false) {
                 $album_last_image = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg';
                 $mediasize = array($this->tnWidth, $this->tnHeight);
             }
         } else {
             $filename = $this->findCover();
             if ($filename == '' || $filename == NULL || $filename == " ") {
                 $album_last_image = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg';
                 $mediasize = array($this->tnWidth, $this->tnHeight);
             } else {
                 $mediasize = false;
                 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;
                         $mediasize = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $filename[0] . '/' . $filename . $ext);
                         break;
                     }
                 }
                 if ($mediasize == false) {
                     $album_last_image = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg';
                     $mediasize = array($this->tnWidth, $this->tnHeight);
                     //@getimagesize($_MG_CONF['path_mediaobjects'] . 'missing.png');
                 }
             }
         }
         $album_media_count = $this->media_count;
         if ($this->last_update > 0) {
             $album_last_update = MG_getUserDateTimeFormat($this->last_update);
             $lang_updated = $_MG_CONF['dfid'] == '99' ? '' : $LANG_MG03['updated_prompt'];
         } else {
             $album_last_update[0] = '';
             $lang_updated = '';
         }
         $lang_updated = $_MG_CONF['dfid'] == '99' ? '' : $LANG_MG03['updated_prompt'];
         if (!COM_isAnonUser()) {
             $lastlogin = DB_getItem($_TABLES['userinfo'], 'lastlogin', "uid = '" . (int) $_USER['uid'] . "'");
             if ($this->last_update > $lastlogin) {
                 $album_last_update[0] = '<font color="red">' . $album_last_update[0] . '</font>';
             }
         }
     } else {
         // nothing in the album yet...
         $filename = $this->findCover();
         if ($filename == '') {
             $album_last_image = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg';
             $mediasize = array($this->tnWidth, $this->tnHeight);
         } else {
             $mediasize = false;
             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;
                     $mediasize = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $filename[0] . '/' . $filename . $ext);
                     break;
                 }
             }
             if ($mediasize == false) {
                 $album_last_image = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg';
                 $mediasize = array($this->tnWidth, $this->tnHeight);
                 // @getimagesize($_MG_CONF['path_mediaobjects'] . 'missing.png');
             }
         }
         $album_last_update[0] = '';
         $lang_updated = '';
     }
     if ($this->tn_attached == 1) {
         $mediasize = false;
         foreach ($_MG_CONF['validExtensions'] as $ext) {
             if (file_exists($_MG_CONF['path_mediaobjects'] . 'covers/cover_' . $this->id . $ext)) {
                 $album_last_image = $_MG_CONF['mediaobjects_url'] . '/covers/cover_' . $this->id . $ext;
                 $mediasize = @getimagesize($_MG_CONF['path_mediaobjects'] . 'covers/cover_' . $this->id . $ext);
                 break;
             }
         }
         if ($mediasize == false) {
             $album_last_image = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg';
             $mediasize = array($this->tnWidth, $this->tnHeight);
             //@getimagesize($_MG_CONF['path_mediaobjects'] . 'missing.png');
         }
     }
     $subalbums = count($this->children);
     $total_images_subalbums = $this->getMediaCount();
     if (isset($_MG_USERPREFS['tn_size']) && $_MG_USERPREFS['tn_size'] != -1) {
         $tn_size = $_MG_USERPREFS['tn_size'];
     } else {
         $tn_size = $MG_albums[$this->parent]->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->parent]->tnHeight;
             $tn_width = $MG_albums[$this->parent]->tnWidth;
             if ($tn_height == 0) {
                 $tn_height = 200;
             }
             if ($tn_width == 0) {
                 $tn_width = 200;
             }
             break;
         default:
             $tn_height = 200;
             $tn_width = 200;
             break;
     }
     if ($mediasize[0] > $mediasize[1]) {
         $ratio = $mediasize[0] / $tn_height;
         $newwidth = $tn_height;
         $newheight = round($mediasize[1] / $ratio);
     } else {
         $ratio = $mediasize[1] / $tn_height;
         $newheight = $tn_height;
         $newwidth = round($mediasize[0] / $ratio);
     }
     $F = new Template($_MG_CONF['template_path']);
     $F->set_var('media_frame', $MG_albums[$this->parent]->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=' . $this->id . '&amp;page=1' . '">', 'media_link_end' => '</a>', 'url_media_item' => $_MG_CONF['site_url'] . '/album.php?aid=' . $this->id . '&amp;page=1', 'media_thumbnail' => $album_last_image, 'media_size' => 'width="' . $newwidth . '" height="' . $newheight . '"', 'media_height' => $newheight, 'media_width' => $newwidth, 'media_tag' => $this->title, 'frWidth' => $newwidth - $MG_albums[$this->parent]->afrWidth, 'frHeight' => $newheight - $MG_albums[$this->parent]->afrHeight));
     $F->parse('media', 'media_frame');
     $media_item_thumbnail = $F->finish($F->get_var('media'));
     $C = new Template(MG_getTemplatePath($this->parent));
     if ($this->parent != 0 && $MG_albums[$this->parent]->display_columns == 1) {
         $C->set_file('cell', 'album_page_body_album_cell_1.thtml');
     } else {
         $C->set_file('cell', 'album_page_body_album_cell.thtml');
     }
     $C->set_var(array('media_item_thumbnail' => $media_item_thumbnail, 'media_item_thumbnail_raw' => $album_last_image, 'u_viewalbum' => $_MG_CONF['site_url'] . '/album.php?aid=' . $this->id . '&amp;page=1', 'album_last_image' => $album_last_image, 'album_title' => $this->title, 'album_media_count' => $this->media_count, 'subalbum_media_count' => $total_images_subalbums, 'album_desc' => PLG_replaceTags($this->description, 'mediagallery', 'album_description'), 'album_last_update' => $album_last_update[0], 'img_height' => $newheight, 'img_width' => $newwidth, 's_media_size' => 'width="' . $newwidth . '" height="' . $newheight . '"', 'border_width' => $newwidth + 20, 'border_height' => $newheight + 20, 'row_height' => $tn_height + 40, 'updated' => $lang_updated, 'lang_album' => $LANG_MG00['album'], 'lang_views' => $LANG_MG03['views'], 'views' => $this->views));
     if ($this->enable_album_views) {
         $C->set_var(array('lang_views' => $LANG_MG03['views'], 'views' => $this->views));
     } else {
         $C->set_var(array('lang_views' => '', 'views' => ''));
     }
     if ($subalbums > 0) {
         $C->set_var(array('subalbumcount' => '(' . $subalbums . ')', 'lang_subalbums' => $LANG_MG01['subalbums']));
     } else {
         $C->set_var(array('subalbumcount' => '', 'lang_subalbums' => ''));
     }
     PLG_templateSetVars('mediagallery', $C);
     $C->parse('output', 'cell');
     $celldisplay = $C->finish($C->get_var('output'));
     return $celldisplay;
 }
Example #29
0
 /**
  * Returns text ready for display.
  *
  * @param   string  $text         Text to prepare for display
  * @param   string  $postmode     Indicates if text is html, adveditor, wikitext or plaintext
  * @param   int     $version      version of GLText engine
  * @return  string  Escaped String
  * @access  public
  *
  */
 public static function getDisplayText($text, $postmode, $version)
 {
     if ($version == GLTEXT_FIRST_VERSION) {
         // first version
         if ($postmode == 'plaintext') {
             $text = COM_nl2br($text);
         }
         if ($postmode == 'wikitext') {
             $text = self::_editUnescape($text, $postmode);
             $text = self::renderWikiText($text);
         }
     } else {
         // latest version
         if ($postmode == 'html' || $postmode == 'adveditor') {
             // Get rid of any newline characters
             $text = str_replace("\n", '', $text);
             $text = self::_handleSpecialTag_callback($text, array('[code]', '[/code]', '<pre><code>', '</code></pre>'), '_escapeSPChars');
             $text = self::_handleSpecialTag_callback($text, array('[raw]', '[/raw]', '<!--raw--><span class="raw">', '</span><!--/raw-->'), '_escapeSPChars');
         }
         if ($postmode == 'plaintext') {
             $text = htmlspecialchars($text, ENT_QUOTES, COM_getEncodingt());
             $text = COM_makeClickableLinks($text);
             $text = COM_nl2br($text);
         }
         if ($postmode == 'wikitext') {
             $text = self::_editUnescape($text, $postmode);
             $text = self::renderWikiText($text);
             //              $text = self::_htmLawed($text, 'story.edit');
         }
         $text = COM_checkWords($text);
     }
     $text = PLG_replaceTags(self::_displayEscape($text));
     return $text;
 }
Example #30
0
 public function displayThumb($opt = array())
 {
     global $_USER, $_CONF, $_MG_CONF, $_TABLES, $LANG_MG03, $LANG_MG01;
     $sortOrder = isset($opt['sortorder']) ? $opt['sortorder'] : 0;
     $searchmode = isset($opt['searchmode']) ? $opt['searchmode'] : 0;
     $album = isset($opt['album_id']) ? $opt['album_id'] : NULL;
     $mode = isset($opt['imageonly']) ? $opt['imageonly'] : 0;
     // $mode = 1 return image only
     if ($album === NULL) {
         $album = new mgAlbum($this->album_id);
     }
     $type = $this->type;
     $_MG_USERPREFS = MG_getUserPrefs();
     // $type == 1 video
     // $type == 2 audio
     if (($type == 1 || $type == 2 || $type == 5) && ($album->playback_type == 0 || $album->playback_type == 1) && $_MG_CONF['popup_from_album'] == 1) {
         if ($album->playback_type == 0) {
             if ($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 = $this->media_size;
                     $new_y += $tnsize[0];
                     if ($tnsize[1] > $new_x) {
                         $new_x = $tnsize[1];
                     }
                 }
                 if ($album->playback_type == 0) {
                     $url_display_item = self::getHref_showvideo($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...
                 $playback_options['height'] = $_MG_CONF['swf_height'];
                 $playback_options['width'] = $_MG_CONF['swf_width'];
                 $poResult = DB_query("SELECT * FROM {$_TABLES['mg_playback_options']} " . "WHERE media_id='" . addslashes($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->resolution_x == 0 && $this->remote_media != 1) {
                         $filepath = self::getFilePath('orig', $this->filename, $this->mime_ext);
                         $size = @filesize($filepath);
                         // skip files over 8M in size..
                         if ($size < 8388608) {
                             list($resolution_x, $resolution_y) = self::getResolutionID3($filepath);
                         }
                     } 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 ($type == 5) {
                     $resolution_x = 460;
                     $resolution_y = 380;
                 }
                 $url_display_item = self::getHref_showvideo($this->id, $resolution_y, $resolution_x);
             }
         } else {
             $url_display_item = $_MG_CONF['site_url'] . '/download.php?mid=' . $this->id;
         }
     } else {
         if ($album->useAlternate == 1 && $type != 5 && !empty($this->remote_url)) {
             $url_display_item = $this->remote_url;
         } else {
             $url_display_item = $_MG_CONF['site_url'] . '/media.php?f=0' . '&amp;sort=' . $sortOrder . '&amp;s=' . $this->id;
         }
     }
     $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 {
         if ($searchmode == 1) {
             $tn_size = $_MG_CONF['search_tn_size'];
         } else {
             $tn_size = $album->tn_size;
         }
     }
     list($tn_width, $tn_height) = self::getTNSize($tn_size, $album->tnWidth, $album->tnHeight);
     list($newwidth, $newheight) = self::getImageWH($this->media_size[0], $this->media_size[1], $tn_width, $tn_height);
     if (!isset($resolution_x)) {
         $resolution_x = $newwidth;
     }
     if (!isset($resolution_y)) {
         $resolution_y = $newheight;
     }
     $username = '******';
     if ($this->owner_id != '' && $this->owner_id > 1) {
         $username = DB_getItem($_TABLES['users'], 'username', "uid=" . intval($this->owner_id));
     }
     $filepath = self::getFilePath('orig', $this->filename, $this->mime_ext);
     $fs_bytes = @filesize($filepath);
     $fileSize = MG_getSize($fs_bytes);
     $direct_url = self::getFileUrl('disp', $this->filename, $this->mime_ext);
     $direct_path = self::getFilePath('disp', $this->filename, $this->mime_ext);
     if (!file_exists($direct_path)) {
         $direct_url = self::getFileUrl('disp', $this->filename, 'jpg');
     }
     $edit_item = '';
     if ($album->access == 3) {
         $edit_item = '<a href="' . $_MG_CONF['site_url'] . '/admin.php?mode=mediaedit&amp;s=1&amp;album_id=' . $this->album_id . '&amp;mid=' . $this->id . '">' . $LANG_MG01['edit'] . '</a>';
     }
     // build the small rating bar
     $rating_box = '';
     if ($album->enable_rating > 0) {
         require_once $_CONF['path'] . 'plugins/mediagallery/include/lib-rating.php';
         $starSize = $_MG_CONF['use_large_stars'] == 1 ? '' : 'sm';
         $rating_box = MG_getRatingBar($album->enable_rating, $this->owner_id, $this->id, $this->votes, $this->rating, $starSize);
     }
     $hrefdirect = '';
     if ($this->type == 0) {
         // standard image
         if ($this->remote == 1) {
             $hrefdirect = $this->remote_url;
         } else {
             $hrefdirect = $direct_url;
         }
     }
     $caption = PLG_replaceTags(str_replace('$', '&#36;', $this->title));
     if ($searchmode == 1) {
         $templatePath = MG_getTemplatePath_byName($_MG_CONF['search_album_skin']);
     } else {
         $templatePath = MG_getTemplatePath($this->album_id);
     }
     $L = COM_newTemplate($templatePath);
     $L->set_file('media_link', 'medialink.thtml');
     $L->set_var(array('hrefdirect' => $hrefdirect, 'href' => $url_media_item, 'caption' => $caption, 'id' => 'id' . rand()));
     $media_start_link = $L->finish($L->parse('media_link_start', 'media_link'));
     if ($searchmode == 1) {
         $skin = $_MG_CONF['search_frame_skin'];
         $info = array('media_type' => $this->type, 'mime_type' => $this->mime_type, 'media_filename' => $this->filename, 'media_mime_ext' => $this->mime_ext, 'remote_media' => $this->remote_url, 'media_tn_attached' => $this->tn_attached);
         list($media_thumbnail, $media_thumbnail_file, $media_size) = self::getThumbInfo($info, $tn_size);
     } else {
         $skin = $album->image_skin;
         $media_thumbnail = $this->media_thumbnail;
     }
     $media_item_thumbnail = MG_getFramedImage($skin, $this->title, $url_media_item, $media_thumbnail, $newwidth, $newheight, $media_start_link);
     if ($mode == 1) {
         return $media_item_thumbnail;
     }
     $edit_link = '';
     if (($type == 1 || $type == 2 || $type == 5) && ($album->playback_type == 0 || $album->playback_type == 1) && $_MG_CONF['popup_from_album'] == 1) {
         // check to see if comments and rating are enabled, if not, put a link to edit...
         if ($album->access == 3) {
             $edit_link = '<br' . XHTML . '><a href="' . $_MG_CONF['site_url'] . '/admin.php?mode=mediaedit&amp;s=1&amp;album_id=' . $this->album_id . '&amp;mid=' . $this->id . '">' . $LANG_MG01['edit'] . '</a>';
         }
     }
     if ($_MG_CONF['use_upload_time'] == 1) {
         $media_time = MG_getUserDateTimeFormat($this->upload_time);
     } else {
         $media_time = MG_getUserDateTimeFormat($this->time);
     }
     $media_title = !empty($this->title) ? PLG_replaceTags($this->title) : '';
     $T = COM_newTemplate($templatePath);
     $T->set_file(array('media_cell_image' => 'album_page_media_cell.thtml', 'mp3_podcast' => 'mp3_podcast.thtml'));
     if ($this->mime_type == 'audio/mpeg' && $album->mp3ribbon) {
         $T->set_var(array('mp3_file' => self::getFileUrl('orig', $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('mp3_podcast', '');
     }
     $T->set_var(array('edit_link' => $edit_link, 'play_now' => '', 'download_now' => $_MG_CONF['site_url'] . '/download.php?mid=' . $this->id, 'play_in_popup' => self::getHref_showvideo($this->id, $resolution_y, $resolution_x), 'row_height' => $tn_height, 'media_title' => $media_title, 'media_description' => PLG_replaceTags(nl2br($this->description)), 'media_tag' => strip_tags($this->title), 'media_time' => $media_time[0], 'media_owner' => $username, 'media_item_thumbnail' => $media_item_thumbnail, '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, 'rating_box' => $rating_box));
     if ($album->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&amp;swhere=1&amp;keywords=' . $searchKeyword . '&amp;keyType=any">' . $keyWords[$i] . '</a>';
             }
             $T->set_var(array('enable_keywords' => 1, 'media_keywords' => $kwText, 'lang_keywords' => $LANG_MG01['keywords']));
         } else {
             $T->set_var('lang_keywords', '');
         }
     } else {
         $T->set_var(array('enable_keywords' => '', 'lang_keywords' => ''));
     }
     if ($album->enable_comments) {
         $link = '<a href="' . $_MG_CONF['site_url'] . '/media.php?f=0' . '&amp;sort=' . $sortOrder . '&amp;s=' . $this->id . '">' . $LANG_MG03['comments'] . '</a>';
         $cmtLink = $LANG_MG03['comments'];
         $cmtLink_alt = $link;
         if ($type == 4 || $type == 1 && $album->playback_type != 2 || $type == 2 && $album->playback_type != 2 || $type == 5 && $album->playback_type != 2) {
             $cmtLink = $link;
             $cmtLink_alt = '';
         }
         $T->set_var(array('media_comments_count' => $this->comments, 'lang_comments' => $cmtLink, 'lang_comments_hot' => $cmtLink_alt));
         $T->set_var('media_comments', $album->enable_comments);
     }
     if ($album->enable_views) {
         $T->set_var(array('media_views_count' => $this->views, 'lang_views' => $LANG_MG03['views']));
         $T->set_var('media_views', $album->enable_views);
     }
     PLG_templateSetVars('mediagallery', $T);
     return $T->finish($T->parse('media_cell', 'media_cell_image'));
 }