Page 1 of 1

External Pages Question - RSS enhancement

Posted: Wed Feb 03, 2010 5:34 pm
by sdotson
I successfully got the external pages "mod" working using battye's instructions. Works great and can be found here:

http://www.mcadforums.com/rss.php (needs some cleaning up, not done yet).

So I decided to take it a step further and use this same code to create an RSS feed (phpbb's built in feeds will pull every reply, I only want the first post in a topic)

So I used the same code in the php file (as in the example above) but changed the template file to look like this:

Code: Select all

<?xml version="1.0" encoding="windows-1252"?>
 <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
      <channel>
        <title>mCADForums.com News Feed</title>
        <description>mCADForums.com News Feed</description>
        <link>http://www.mcadforums.com</link>
        <language>en</language>
        <copyright>mCADForums.com</copyright>
        <generator>mCADForums.com</generator>
        <ttl>30</ttl>
        <atom:link href="http://www.mcadforums.com/mcadrss.php" rel="self" type="application/rss+xml" />

<!-- BEGIN announcements -->

        <item>
          <title>{announcements.TOPIC_TITLE}</title>
          <description>{announcements.POST_TEXT}</description>
          <link>{announcements.POST_LINK}</link>
          <pubDate>{announcements.POST_DATE}</pubDate>
        </item>

<!-- END announcements -->

      </channel>
 </rss>
Problem is, there does not seem to be any NEW items being generated. If you place this url in your browser:

http://www.mcadforums.com/mcadrss.php

You'll see no content. But then add it to Google reader and you'll notice there is content there. But for some reason aggregators are not picking up on any new posts. (I'm using twitterfeed to feed posts from a rss stream to a twitter account)

Any ideas?

Re: External Pages Question - RSS enhancement

Posted: Thu Feb 04, 2010 4:30 am
by battye
Hi sdotson, welcome to CMX.

If I paste that address in my browser I see content, this is what I see:
mCADForums.com News Feed http://www.mcadforums.com en mCADForums.com mCADForums.com 30 Every once in awhile I have this small problem, and I have not been able to determine the ryme or reason for it:

I sometimes put a sketch into a part that's just for a mating reference for when it goes into an assembly. Sometimes it's just a point, sometimes a circle, or a line whose endpoint can be used. Problem is, now and then I find that once this component is placed into a particular assembly, the sketch cannot be seen, and therefore cannot be accessed for mating purposes. And the only right-click option I'm given is to hide it. (?) Rebuilding doesn't change anything. The sketch in the component is just a stand-alone sketch; it's not associated with any feature, so by default it shows when the part is open - just not in the assembly. No combination of hiding or showing in the part makes any difference in the assembly; it remains invisible/inaccessable. What gives? ./forums/viewtopic.php?t=10791&sid=45aa549cd8ea48258eb0827b79256c4e Wed, 03 Feb 2010 16:46:03 +0000 Test post ./forums/viewtopic.php?t=10789&sid=45aa549cd8ea48258eb0827b79256c4e Wed, 03 Feb 2010 12:30:00 +0000 I wonder what software was used?

http://is.gd/7CNmN ./forums/viewtopic.php?t=10788&sid=45aa549cd8ea48258eb0827b79256c4e Wed, 03 Feb 2010 11:34:28 +0000 So how do you guys approach this?

Do you create a custom Table as a sketch symbol?

Do you create a Table Style then overlay text on it?

Do you import an .xls as an OLE or image?

I sure wish IV had an iPart Table as a built in solution

We currently have a "Part No." symbol which consist of a custom sketched table with 1 row and 1 column that gets placed in the upper left corner of the border...and right now I am using multiple variations of these symbols to represent 1,2,3 column variations as "A" "B" "C", etc..columns, and consequently overriding the dim value (hide it) and manually type whihc column I want...we also then include more symbols to correlate with the qty of column symbols called "Part No. Add a row (1 column)" etc..

Anyone have a more clever way of tackling this dilemma? ./forums/viewtopic.php?t=10786&sid=45aa549cd8ea48258eb0827b79256c4e Wed, 03 Feb 2010 10:09:11 +0000 I need an example of an overly complicated detail drawing. Lots of notes, leaders, unnecessary GDT etc...

I need to use it in a presentation. I can black out any sensitive data and it'll only be on screen, not downloadable.

Thanks... ./forums/viewtopic.php?t=10785&sid=45aa549cd8ea48258eb0827b79256c4e Tue, 02 Feb 2010 22:02:03 +0000 http://www.tweaktown.com/guides/3116/tw ... index.html

This article was very interesting...thought you guys would like to know

...we are about to embark on a whole new level of hardware performance tech here soon!

i7's QuadCore's
SLI Graphics
SSD's
64bit OS
64bit Apps
Multi thrd Apps

...looks like its all coming together soon to achieve new performance speeds! ./forums/viewtopic.php?t=10783&sid=45aa549cd8ea48258eb0827b79256c4e Tue, 02 Feb 2010 09:41:39 +0000 Not being on the inside circles of SW, I see the attendance for SW World in the neighborhood of 5000 people. That's more than 2/3 of the entire AU attendance and yet it's only for one Autodesk's competing product lines. Am I missing something or is the ratio of SW users to Inventor users that disproportionate? ./forums/viewtopic.php?t=10782&sid=45aa549cd8ea48258eb0827b79256c4e Tue, 02 Feb 2010 07:13:37 +0000 We have been running Design Review 2008 and 2009 for a couple of years with few problems. We take snapshots of 3D models created in inventor, add markups such as callouts, submit these to our graphics department. The graphic artist pulls the image from the Inventor 3D file, ensures proper layering for our custome and adds callouts as requested by our developers.

We recently started seeing models created in Inventor 2009, with many of the images being huge (in excess of 15 Meg). Our graphics coordinator recommended upgrading to Design review 2010 to be able to open some of the larger dwfs. We are seeing several issues with Design Review 2010:

Some people cannot install the program - the computer locks before completeion.
Some people load the program successfully, but cannot run the program (they get the hourglass briefly, then it goes away and nothing else occurs.
Many people's computer simply locks up when opening a dwf of any size.
Others open the dwf, but it shuts down Excel and/or Access.

All of this is acurring on laptops running Windows XP Pro with Service Pack 2, with at least 1.5 Gig of RAM and some with as much as 2.5 Gig. Plenty of virtual RAM is available in all cases.

Anyone out there have any ideas???? ./forums/viewtopic.php?t=10781&sid=45aa549cd8ea48258eb0827b79256c4e Mon, 01 Feb 2010 16:32:51 +0000 Can anyone recommend a good step by step tutorial online for the "Cable and Harness" portion of Inventor 2010? I seem to be struggling through this on my own. Thanks in advance for any help. ./forums/viewtopic.php?t=10779&sid=45aa549cd8ea48258eb0827b79256c4e Sun, 31 Jan 2010 19:56:24 +0000 How can a company that makes a living creating CAD software be so bad at math?

I've attached a picture of the BOM interface showing 2 iAssemblies with virtual parts placed into an assembly. No matter what I do, when inventor adds the quantities of the virtual part it defaults to the quantity in the first assembly times the number of assemblies.
As you can see the quantity should be 20, not 28. If I place the assembly with 6 parts first the total quantity shows as 12.

This is very frustrating in that I use a lot of iAssemblies with fasteners and I would like to replace the fastener parts with virtual parts in order to streamline my large assemblies.

Can someone please verify weather or not this is still an issue with 2010?
Does anyone have any suggestions to overcome this issue?

Thanks,
Keith ./forums/viewtopic.php?t=10777&sid=45aa549cd8ea48258eb0827b79256c4e Sun, 31 Jan 2010 08:41:22 +0000
Could it have been the template cache had not updated? (that could have been what gave you the blank screen)

Re: External Pages Question - RSS enhancement

Posted: Thu Feb 04, 2010 2:25 pm
by sdotson
Yep, actually figured it out and was on my way back here to reply. It was the cache. Thanks for reminding me.

While we are on this subject, do you know if there is a way to make individual pages NOT be cached?

Re: External Pages Question - RSS enhancement

Posted: Thu Feb 04, 2010 8:45 pm
by sdotson
One more question... what code would I need in the php file to only post topic created by people NOT in the "Newly registered users" group. This way I can be sure a spammer does not end up posting to the RSS or XML feeds.

Thanks

Re: External Pages Question - RSS enhancement

Posted: Sat Feb 06, 2010 7:04 am
by battye
To do a check you can do something like this, this gets the group id of the newly registered users group:

Code: Select all

		$sql = 'SELECT group_id
			FROM ' . GROUPS_TABLE . "
			WHERE group_name = 'NEWLY_REGISTERED'";
		$result = $db->sql_query($sql);
		$group_id = (int) $db->sql_fetchfield('group_id'); // this is the group id of the "newly registered users" group
		$db->sql_freeresult($result);
Then you can match that against the group_id in the users table for a particular user_id... so for example 1 (which is what you are using isn't it?) of the blog post it might be something like (untested, and there might even be a phpBB3 function for this - I don't know offhand):

Code: Select all

$sql = 'SELECT group_id FROM ' . USERS_TABLE . '
WHERE user_id = ' . $topics_row['topic_poster'];
$result = $db->sql_query($sql);
$group_id_for_user = (int) $db->sql_fetchfield('group_id');
$db->sql_freeresult($result);
Then you can do a check like this:

Code: Select all

if( $group_id == $group_id_for_user )
{
// then the user is in the group "newly registered users"
// do stuff
}

Re: External Pages Question - RSS enhancement

Posted: Mon Feb 08, 2010 12:51 pm
by sdotson
Interesting...If i use your code I get the error:

SELECT group_id FROM phpbb306_users WHERE user_id =

However if I change the line to read:

Code: Select all

WHERE user_id = ' . $posts_row['topic_poster'];
The script runs but returns no values (no posts). I feel we are close, very close.

And thanks for the help.

The code in question so far...

Code: Select all

while ($posts_row = $db->sql_fetchrow($posts_result))
{

$topic_title = $posts_row['topic_title'];
$topic_author = get_username_string('full', $posts_row['topic_poster'], $posts_row['topic_first_poster_name'], $posts_row['topic_first_poster_colour']);
$topic_date = $user->format_date($posts_row['topic_time']);
$topic_link = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t=" . $posts_row['topic_id']);

$post_text = nl2br($posts_row['post_text']);

$bbcode = new bbcode(base64_encode($bbcode_bitfield));
$bbcode->bbcode_second_pass($post_text, $posts_row['bbcode_uid'], $posts_row['bbcode_bitfield']);

$post_text = smiley_text($post_text);

//check to see if user is allowed to post
 $sql = 'SELECT group_id FROM ' . USERS_TABLE . '
WHERE user_id = ' . $posts_row['topic_poster'];
$result = $db->sql_query($sql);
$group_id_for_user = (int) $db->sql_fetchfield('group_id');
$db->sql_freeresult($result);
//check to see if user is allowed to post


 //check to see if user is allowed to post   
    $sql = 'SELECT group_id
         FROM ' . GROUPS_TABLE . "
         WHERE group_name = 'NEWLY_REGISTERED'";
      $result = $db->sql_query($sql);
      $group_id = (int) $db->sql_fetchfield('group_id'); // this is the group id of the "newly registered users" group
      $db->sql_freeresult($result);


if( $group_id == $group_id_for_user ) {

$template->assign_block_vars('announcements', array(
'TOPIC_TITLE' => $topic_title,
'POST_AUTHOR' => $topic_author,
'POST_DATE' => $topic_date,
'POST_LINK' => $topic_link,
'POST_TEXT' => censor_text($post_text),
));
}
}



page_header('External page');

$template->set_filenames(array(
'body' => 'mcadrss.html'
));

page_footer();
?> 

Re: External Pages Question - RSS enhancement

Posted: Wed Feb 10, 2010 12:34 pm
by sdotson
I really need to get this working. I'd be happy to shoot a paypal donation over your (or anyone else's) way if they could help me get this working. Thanks..

Re: External Pages Question - RSS enhancement

Posted: Wed Feb 10, 2010 12:45 pm
by battye
If you want it to show posts by users NOT in the newly registered group, you need to change:

Code: Select all

if( $group_id == $group_id_for_user ) {
To

Code: Select all

if( $group_id != $group_id_for_user ) {
But also try creating a test account and making a post by a user in the newly registered group to make sure it works correctly. If it doesn't, find:

Code: Select all

if( $group_id != $group_id_for_user ) {
And before add:

Code: Select all

echo "GROUP ID: " . $group_id  . " --- " . UG ID: " . $group_id_for_user . "<br />";
And post the resulting output here so we can compare the ID's.

Re: External Pages Question - RSS enhancement

Posted: Wed Feb 10, 2010 7:08 pm
by sdotson
Doh... I missed the == and != (plus I did not have the newly registered users group turned of, double doh!) Thank you very much for your time and help.

So what would be fair compensation for your time?

BTW I am posting my complete php file here in case anyone else finds it useful.

Code: Select all

<?php
/*
* home.php
* Description: example file for displaying latest posts and topics
* by battye (for phpBB.com MOD Team)
* September 29, 2009
*/

define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './forums/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('viewforum');


// Function Where Clauses

    /* create_where_clauses( int[] gen_id, String type )
    * This function outputs an SQL WHERE statement for use when grabbing
    * posts and topics */

    function create_where_clauses($gen_id, $type)
    {
    global $db, $auth;

    $size_gen_id = sizeof($gen_id);

    switch($type)
    {
    case 'forum':
    $type = 'forum_id';
    break;
    case 'topic':
    $type = 'topic_id';
    break;
    default:
    trigger_error('No type defined');
    }

    // Set $out_where to nothing, this will be used of the gen_id
    // size is empty, in other words "grab from anywhere" with
    // no restrictions
    $out_where = '';

    if ($size_gen_id > 0)
    {
    // Get a list of all forums the user has permissions to read
    $auth_f_read = array_keys($auth->acl_getf('f_read', true));

    if ($type == 'topic_id')
    {
    $sql = 'SELECT topic_id FROM ' . TOPICS_TABLE . '
    WHERE ' . $db->sql_in_set('topic_id', $gen_id) . '
    AND ' . $db->sql_in_set('forum_id', $auth_f_read);

    $result = $db->sql_query($sql);

    while ($row = $db->sql_fetchrow($result))
    {
    // Create an array with all acceptable topic ids
    $topic_id_list[] = $row['topic_id'];
    }

    unset($gen_id);

    $gen_id = $topic_id_list;
    $size_gen_id = sizeof($gen_id);
    }

    $j = 0;

    for ($i = 0; $i < $size_gen_id; $i++)
     {
    $id_check = (int) $gen_id[$i]; // If the type is topic, all checks have been made and the query can start to be built if( $type == 'topic_id' ) { $out_where .= ($j == 0) ? 'WHERE ' . $type . ' = ' . $id_check . ' ' : 'OR ' . $type . ' = ' . $id_check . ' '; } // If the type is forum, do the check to make sure the user has read permissions else if( $type == 'forum_id' && $auth->acl_get('f_read', $id_check) )
    {
    $out_where .= ($j == 0) ? 'WHERE ' . $type . ' = ' . $id_check . ' ' : 'OR ' . $type . ' = ' . $id_check . ' ';
    }

    $j++;
    }
    }

    if ($out_where == '' && $size_gen_id > 0)
    {
    trigger_error('A list of topics/forums has not been created');
    }

    return $out_where;
    }
 
 
//Define what forums to pick in the array below


$forum_id = array(13,66,5,20,3,10,11);
$forum_id_where = create_where_clauses($forum_id, 'forum');


$search_limit = 10;

$posts_ary = array(
'SELECT' => 'p.*, t.*',

'FROM' => array(
POSTS_TABLE => 'p',
),

'LEFT_JOIN' => array(
array(
'FROM' => array(TOPICS_TABLE => 't'),
'ON' => 't.topic_first_post_id = p.post_id'
)
),

'WHERE' => str_replace( array('WHERE ', 'forum_id'), array('', 't.forum_id'), $forum_id_where) . '
AND t.topic_status <> ' . ITEM_MOVED . '
AND t.topic_approved = 1',

'ORDER_BY' => 'p.post_id DESC',
);

$posts = $db->sql_build_query('SELECT', $posts_ary);

$posts_result = $db->sql_query_limit($posts, $search_limit);









while ($posts_row = $db->sql_fetchrow($posts_result))
{

$topic_title = $posts_row['topic_title'];
$topic_author = get_username_string('full', $posts_row['topic_poster'], $posts_row['topic_first_poster_name'], $posts_row['topic_first_poster_colour']);
$topic_date = $user->format_date($posts_row['topic_time']);
$topic_link = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t=" . $posts_row['topic_id']);

$post_text = nl2br($posts_row['post_text']);

$bbcode = new bbcode(base64_encode($bbcode_bitfield));
$bbcode->bbcode_second_pass($post_text, $posts_row['bbcode_uid'], $posts_row['bbcode_bitfield']);

$post_text = smiley_text($post_text);

//determine what group the user belongs to
 $sql = 'SELECT group_id FROM ' . USERS_TABLE . '
WHERE user_id = ' . $posts_row['topic_poster'];
$result = $db->sql_query($sql);
$group_id_for_user = (int) $db->sql_fetchfield('group_id');
$db->sql_freeresult($result);



 //check to see if the user is allowed to post based on group, could change this to "content managers" one day vs newly registered
    $sql = 'SELECT group_id
         FROM ' . GROUPS_TABLE . "
         WHERE group_name = 'NEWLY_REGISTERED'";
      $result = $db->sql_query($sql);
      $group_id = (int) $db->sql_fetchfield('group_id'); // this is the group id of the "newly registered users" group
      $db->sql_freeresult($result);

//wrap the block_var assignments in an if statement
if( $group_id != $group_id_for_user ) {

$template->assign_block_vars('announcements', array(
'TOPIC_TITLE' => $topic_title,
'POST_AUTHOR' => $topic_author,
'POST_DATE' => $topic_date,
'POST_LINK' => $topic_link,
'POST_TEXT' => censor_text($post_text),
));
}
}



page_header('External page');

$template->set_filenames(array(
'body' => 'mcadrss.html'
));

page_footer();
?> 

Re: External Pages Question - RSS enhancement

Posted: Thu Feb 11, 2010 3:48 am
by battye
I'm glad it's all working for you. :)

No compensation is needed, but if you or someone you know lives in America I would love to get a copy of a cricket match which is only viewable to users living in the US: http://forums.cricketmx.com/viewtopic.p ... 787#p98787

Re: External Pages Question - RSS enhancement

Posted: Thu Feb 11, 2010 1:33 pm
by sdotson
I'll see if I get ESPN360 (not sure). If I do I'll see what I can do for you. (Maybe I'll finally figure out the rules to cricket :) )Thanks!