Facebook  Twitter 

SMFHacks.com

+-

SMFHacks.com

+- User Information

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+- Forum Stats

Members
Total Members: 4257
Latest: Alex998.
New This Month: 1
New This Week: 0
New Today: 0
Stats
Total Posts: 43295
Total Topics: 7523
Most Online Today: 208
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 218
Total: 218

Author Topic: Last Commented Photos PHP Article  (Read 4278 times)

0 Members and 1 Guest are viewing this topic.

Offline rumboogy

  • Full Member
  • ***
  • Posts: 215
    • View Profile
    • Smorgasboard Forums
Last Commented Photos PHP Article
« on: August 24, 2009, 06:58:32 pm »
Even though the newest version of SMF Gallery includes a latest comments list, I have another list that my member like better because they can actually see the comment before clicking on the thumbnail...but I have been getting an error with the code that I cannot figure out...

Here is the error:

Quote
8: Undefined variable: scripturl
File: /home/razorbi/public_html/arkansasbiker/Themes/default/TPortal.template.php(586) : eval()'d code
Line: 54

And here is the php article...but I can't figure out what is wrong with that line.

Code: [Select]
/***************************
Latest comments for
SMF Gallery
By Dragooon
****************************/
global $db_prefix;
// If you want them to show from specific pictures, alter this.
$pic_ids = array();

// Get the current page
$current_page = isset($_REQUEST['page']) ? $_REQUEST['page'] : '';

// Sorting and starting!
$start = isset($_GET['start']) ? $_GET['start'] : 0;
$per_page = 10;
if(isset($_REQUEST['sort']))
if($_REQUEST['sort'] == 'asc')
$sort = 'c.ID_COMMENT ASC';
else
$sort = 'c.ID_COMMENT DESC';
else
$sort = 'c.ID_COMMENT DESC';
// For pagination
if(count($pic_ids) > 0)
   $where_clause = 'WHERE p.ID_PICTURE IN ('.implode(',',$pic_ids).')';
else
   $where_clause = '';
$query_page = db_query(" SELECT c.ID_COMMENT, c.ID_MEMBER, c.comment, c.date,
p.ID_PICTURE, p.title, p.thumbfilename, p.commenttotal, p.views, mem.realName
FROM {$db_prefix}gallery_comment AS c
INNER JOIN {$db_prefix}gallery_pic AS p ON (p.ID_PICTURE = c.ID_PICTURE)
                                        INNER JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = c.ID_MEMBER)
$where_clause",__FILE__,__LINE__);
$total = mysql_num_rows($query_page);
mysql_free_result($query_page);
$page_index = constructPageIndex($scripturl.'?page='.$current_page, $start, $total, $per_page);

// Now load the comments
$coms = getNewestComments($pic_ids, $per_page, $sort, $start);

echo  '<div align="right">Pages : '.$page_index.'</div>
<table cellpadding="0" cellspacing="0" border="0" width="100%" class="tborder">'; 
foreach($coms as $c) {
echo '
<tr>
<td style="padding: 1px 1px 0 1px;">
<table width="100%" cellpadding="3" cellspacing="0" border="0" class="tborder">
<tr>
<td class="windowbg2">
<table width="100%" cellpadding="5" cellspacing="0" style="table-layout: fixed;">
<tr>
<td valign="top" width="16%" rowspan="2" style="overflow: hidden;" align="center">
<a href="'.$scripturl,'?action=gallery;sa=view;id='.$c['id_pic'].'">',$c['pic_title'],'</a><br />
<a href="'.$scripturl,'?action=gallery;sa=view;id='.$c['id_pic'].'"><img src="'.$c['thumb'].'" /></a>
Views : '.$c['views'],'<br />
Comments : ',$c['total_com'],'<br />
By : ',$c['member'],'<br />
                                                                                On : '.$c['date'].'
</td>
</tr>
</table>
</td>
<td valign="top" width="85%" height="100%" class="windowbg2">
<table width="100%" border="0">
<tr>
<td valign="middle">
',$c['msg'],'
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>';
}
echo '</table>';
echo  '<div align="right">Pages : '.$page_index.'</div>';
// This function loads all the comments we need!
function getNewestComments($pic_ids = array(), $limit = 0, $sort = 'c.ID_COMMENT DESC', $start = 0) {
global $db_prefix, $ID_MEMBER, $scripturl, $context, $memberContext, $boardurl;
        if(count($pic_ids) > 0)
             $where_clause = 'WHERE p.ID_PICTURE IN ('.implode(',',$pic_ids).')';
        else
             $where_clause = '';
$limit = !empty($start) ? "LIMIT $start,$limit" : "LIMIT $limit";

$request = db_query("
SELECT c.ID_COMMENT, c.ID_MEMBER, c.comment, c.date,
p.ID_PICTURE, p.title, p.thumbfilename, p.commenttotal, p.views, mem.realName
FROM {$db_prefix}gallery_comment AS c
INNER JOIN {$db_prefix}gallery_pic AS p ON (p.ID_PICTURE = c.ID_PICTURE)
                                        INNER JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = c.ID_MEMBER)
$where_clause
ORDER BY $sort
$limit",__FILE__,__LINE__);
$members_to_load = array();
$coms = array();
while($row = mysql_fetch_assoc($request)) {
$members_to_load[] = $row['ID_MEMBER'];
$coms[] = array(
'id_com' => $row['ID_COMMENT'],
'id_pic' => $row['ID_PICTURE'],
'id_mem' => $row['ID_MEMBER'],
'msg' => $row['comment'],
'date' => timeformat($row['date']),
'pic_title' => $row['title'],
'member' => '<a href="'.$scripturl.'?action=profile;u='.$row['ID_MEMBER'].'">'.$row['realName'].'</a>',
'total_com' => $row['commenttotal'],
'thumb' => $boardurl.'/gallery/'.$row['thumbfilename'],
'views' => $row['views'],
);
}
// Load Members now
mysql_free_result($request);
return $coms;
}

Anyone have any hints as to what is going on with this...it causes an error (in the forum error log) everytime someone accesses that particular page.

Thanks,

Wally
Rumboogy
"Yeah, I got way too many irons in the fire"
Biker Site:      http://www.razorbiker.com
Biker Site:      http://www.arkansasbiker.net
Zumo GPS:     http://www.zumoforums.com
Personal Site:  http://www.wallyjarratt.com

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16452
    • View Profile
Re: Last Commented Photos PHP Article
« Reply #1 on: August 24, 2009, 09:19:02 pm »
Just put the following before all the code
Code: [Select]
global $scripturl;
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

 

Related Topics

  Subject / Started by Replies Last post
5 Replies
7101 Views
Last post April 23, 2008, 03:17:07 am
by Bec
0 Replies
3950 Views
Last post June 10, 2012, 10:46:16 am
by shaka
1 Replies
3289 Views
Last post May 22, 2015, 11:28:07 am
by SMFHacks
10 Replies
6562 Views
Last post October 10, 2015, 04:51:21 pm
by SMFHacks
1 Replies
3209 Views
Last post April 20, 2016, 09:47:59 am
by SMFHacks

+- Recent Topics

Please Help! by SMFHacks
April 17, 2024, 08:04:55 am

Rate own images by fvlog19
April 11, 2024, 10:56:53 am

Tidy Child Boards on 2.1.4 by SMFHacks
April 04, 2024, 03:54:12 pm

Problems SMF 2.0.19 > 2.1.4 SMF Gallery Pro - Recents Images to overall header by Michel68
March 30, 2024, 12:41:08 pm

Can't DROP 'id_member'; check that column/key exists Datei: by SMFHacks
March 30, 2024, 11:58:20 am

No thumbnails on new uploads by Tonyvic
March 29, 2024, 06:26:18 am

Display the Contact Page for guests by SMFHacks
March 27, 2024, 10:55:43 am

is it possible to add support for odysee.com by fvlog19
March 21, 2024, 08:47:51 am

Request for admin notification by davejo
March 10, 2024, 01:31:59 am

I need help with torrent upload by Ineedsmfhelp
March 09, 2024, 10:01:13 pm

Powered by EzPortal