|
|
|
Re: Looking for hack... [message #19483 is a reply to message #3253] |
Sun, 25 July 2004 23:00 |
zushiba
Messages: 20 Registered: May 2003
Karma: 0
|
Junior Member |
|
|
An include with a crapload of prebuilt functions to return stuff like the last post, forum stats, user profiles and topic functions like creating a topic deleting a topic modifing a topic etc...
it's in the scripts folder somewhere.
EDIT: This has nothing to do with the yahoo user id stuff. You would have to take that up with Yahoo.
[Updated on: Sun, 25 July 2004 23:01] Report message to a moderator
|
|
|
|
Re: Looking for hack... [message #26297 is a reply to message #3259] |
Wed, 13 July 2005 02:23 |
cire
Messages: 19 Registered: June 2005
Karma: 0
|
Junior Member |
|
|
Still extremely new to php and sql! I tried the script and get nothing. Am I supposed to change "$n_posts" to the "$5" or "5". Because when I change it I get error on the line of "function", a parse error.. Keep it "$n_posts", no error but, nothing returned. Tried the rest of the fixes in this TOPIC!
Also with no errors I tried a simple 'echo "test";' nothing. Using 2.6.15! I did a few php files and never had this happen.
Goto http://www.freestylesounds.com/new.php to see, no errors, nothing!
[Updated on: Wed, 13 July 2005 02:25] Report message to a moderator
|
|
|
|
Re: Looking for hack... [message #26300 is a reply to message #26298] |
Wed, 13 July 2005 02:37 |
cire
Messages: 19 Registered: June 2005
Karma: 0
|
Junior Member |
|
|
That was quick! I did that as soon as I do errors.. and i tried it on both '$n_posts''s in different ways and everything. I'm probably missing something extremely dumb.. But the line say 4, "function" blah($5), or (5), or ($n_posts = 5). ERRORS on that line
30 mins later! Just thought my FUD is only testing ready for people but only 1 post. SO It might be working but need to get last 5 posts even if no post today
[Updated on: Wed, 13 July 2005 03:21] Report message to a moderator
|
|
|
Re: Looking for hack... [message #26313 is a reply to message #26300] |
Wed, 13 July 2005 15:01 |
Ilia
Messages: 13241 Registered: January 2002
Karma: 0
|
Senior Member Administrator Core Developer |
|
|
when you are calling a function, you simply need to do
function_name(5);
FUDforum Core Developer
|
|
|
Re: Looking for hack... [message #26327 is a reply to message #26313] |
Wed, 13 July 2005 21:04 |
cire
Messages: 19 Registered: June 2005
Karma: 0
|
Junior Member |
|
|
I did use "5" but as soon as I change it i get
'Parse error: parse error, expecting `')'' in c:\inetpub\wwwroot\new.php on line 7'
Line 7 is the "function forums_posts(5)"!
Just realize after rereading your last post. I was looking at it the wrong way. I have to "call" the function, posts(#).. DUH! Ok so i made the php file named "new.php" I was just go to place it in an iframe and src="new.php". So how do I call the function that why or is there a better way.
[Updated on: Wed, 13 July 2005 21:12] Report message to a moderator
|
|
|
|
Re: Looking for hack... [message #26333 is a reply to message #26328] |
Thu, 14 July 2005 13:07 |
Ilia
Messages: 13241 Registered: January 2002
Karma: 0
|
Senior Member Administrator Core Developer |
|
|
You are not using the code correctly, you are modifying the function defenition rather then calling it. Read up on how to use PHP.
FUDforum Core Developer
|
|
|
|
Re: Looking for hack... [message #27290 is a reply to message #3253] |
Sat, 03 September 2005 09:33 |
Iadnah
Messages: 7 Registered: September 2005
Karma: 0
|
Junior Member |
|
|
This is the method I use (because I HATE fudapi). You'll probably want to edit the way it outputs data to suit your site.
<?php
echo ( "
<table width=\"100%\"><tr id=\"header\"><td><center><strong>.::Last Post in Each Forum::.</strong></center></td></tr></table>
<div id=\"content\">
<center>
<table cellpadding=\"2\" width=\"100%\">
" );
function lastPost($fid)
{
$fname="snip"; //forum database login name
$fpass="snip"; //forum database pass
$fdb="forum"; //name of database forum uses
mysql_connect(localhost,$fname,$fpass);
@mysql_select_db($fdb) or die("Could not connect to database.");
$query="select last_post_date, id, replies, forum_id, last_post_id from fud26_thread where forum_id = '$fid' order by last_post_date desc";
$result=mysql_query($query);
$num=mysql_numrows($result);
$x=0;
while ($x < $num) {
$post_id=mysql_result($result,$x,"id");
$replies=mysql_result($result,$x,"replies");
$last_post_date=mysql_result($result,$x,"last_post_date");
$last_post_id=mysql_result($result,$x,"last_post_id");
$x=$num;
}
$num=mysql_numrows($result);
$x=0;
while ($x < $num) {
$post_id=mysql_result($result,$x,"id");
$replies=mysql_result($result,$x,"replies");
$last_post_date=mysql_result($result,$x,"last_post_date");
$last_post_id=mysql_result($result,$x,"last_post_id");
$url="http://www.uplinklounge.com/forum/index.php?t=msg&th=$post_id";
$x=$num;
}
$query="select name from fud26_forum where id = \"$fid\"";
$result=mysql_query($query);
$num=mysql_numrows($result);
$x=0;
while ($x < $num) {
$forum_name=mysql_result($result,$x,"name");
$x=$num;
}
$query="select subject, poster_id from fud26_msg where id = \"$last_post_id\"";
$result=mysql_query($query);
$num=mysql_numrows($result);
$x=0;
while ($x < $num) {
$poster_id=mysql_result($result,$x,"poster_id");
$subject=mysql_result($result,$x,"subject");
$x=$num;;
}
if (!isset($poster))
{
$poster = "Anonymous Coward";
}
$pdate=date("m/d/Y", $last_post_date);
$ptime=date("g:i A", $last_post_date);
echo ( "
<tr><td width=\"20%\">
<div align=\"right\"><b><a href=\"http://www.uplinklounge.com/forum/index.php?t=thread&frm_id=$fid\">$forum_name</a>: </b></div>
</td>
<td width=\"35%\">
<a href=\"$url\">$subject</a>
</td>
<td>($replies replies)</td>
<td>
<a href=\"http://www.uplinklounge.com/forum/index.php?t=usrinfo&id=$poster_id\">$poster</a>
</td>
<td>
<small>$pdate at $ptime</small>
</td>
</tr>
"
);
mysql_close();
}
lastPost(2);
lastPost(30);
lastPost(8);
lastPost(9);
lastPost(10);
lastPost(12);
lastPost(32);
lastPost(44);
lastPost(42);
lastPost(14);
lastPost(17);
lastPost(37);
lastPost(38);
lastPost(7);
lastPost(41);
echo ( "
</table>
</center>
</div>
" );
?>
I know my code's probably not efficient, but it gets the job done and displays a nice table showing each forum you tell it to, the subject of the last post in each forum, who posted it, when, and how many replies it's gotten. Also, it will have a link to the profile of the poster.
Those numbers where it says lastPost(number); are the id numbers of the forums you want it to get info about. I hope I helped.
|
|
|
Re: Looking for hack... [message #29203 is a reply to message #26336] |
Sat, 03 December 2005 23:17 |
|
Wild_Cat
Messages: 144 Registered: November 2002 Location: Odessa, Ukraine
Karma: 0
|
Senior Member |
|
|
cire | I got the right code on "wild cats" post a few up! I wish he said 2.6.x code in his post.
|
She (me) does not run FUDforum currently on her (my) site.
However, the latest version I had was 2.6.0 and the code did run OK. I attach the latest code I used (to not verify if I made any changes).
If it doesn't work with newest 2.7.x, would Ilya please take a look and may be it's quick to put in the needed modifications (reminding that my code was done on and thanks to your intial example)? Or at least give guidance for others who'd wish to use it as to what've been changed and needs to be modified (or that it will work - anyone's feedback in help for newcomers?)
function fetch_forum_posts($n_posts) /* n_posts is the number of messages you wish to fetch */
{ /* change the following for your forum GLOBALS paths!!! */
include_once "forum/fud/include/GLOBALS.php";
$cid = mysql_connect($DBHOST, $DBHOST_USER, $DBHOST_PASSWORD);
$tbl = $DBHOST_TBL_PREFIX;
$r = mysql_db_query($DBHOST_DBNAME, "SELECT resource_id FROM ".$tbl."group_cache WHERE user_id=0 AND group_cache_opt>>1&1=1", $cid);
$lm='';
while( list($id) = mysql_fetch_row($r) ) $lm .= $id.',';
$lm = substr($lm, 0, -1);
$r = mysql_db_query($DBHOST_DBNAME, "SELECT
".$tbl."msg.id,
".$tbl."msg.subject,
".$tbl."thread.last_post_date,
".$tbl."thread.last_post_id
FROM
".$tbl."thread
INNER JOIN ".$tbl."msg
ON ".$tbl."thread.root_msg_id=".$tbl."msg.id
WHERE
".$tbl."thread.forum_id IN (".$lm.") AND
".$tbl."msg.apr=1
ORDER by
".$tbl."thread.last_post_id DESC
LIMIT ".$n_posts, $cid);
while( $obj = mysql_fetch_object($r) ) {
/* Here you do your actual code, below is a working example */
$tm = date("d/m/Y H:i", $obj->last_post_date);
echo "<p><SPAN CLASS=\"date\">".$tm."</SPAN> - <a href=\"".$WWW_ROOT."index.php?t=msg&goto=".$obj->id."\">".$obj->subject."</a> <a href=\"".$WWW_ROOT."index.php?t=tree&goto=".$obj->last_post_id."\">»»</a></p>\n";
}
mysql_free_result($r);
}
/*Here goes the actual call of the function!
Insert the number of posts you wish to pull instead of 10
And insert the call in the place you wish it to show the list */
fetch_forum_posts(10);
Lady of Avalon
|
|
|
|
|
Re: Looking for hack... [message #29267 is a reply to message #29265] |
Tue, 06 December 2005 21:21 |
Ilia
Messages: 13241 Registered: January 2002
Karma: 0
|
Senior Member Administrator Core Developer |
|
|
FUDAPI is a series of functions found inside scripts/fudapi.inc.php that allow easy message retrieval mechanisms, etc...
FUDforum Core Developer
|
|
|
|
Re: Looking for hack... [message #29279 is a reply to message #29276] |
Thu, 08 December 2005 14:25 |
Ilia
Messages: 13241 Registered: January 2002
Karma: 0
|
Senior Member Administrator Core Developer |
|
|
FUDAPI has fairly extensive documentation inside the script itself, that explains how all the functions work and what parameters do they take and return.
FUDforum Core Developer
|
|
|