[geeklog-cvs] geeklog-1.3/public_html article.php,1.42,1.43 index.php,1.56,1.57 lib-common.php,1.317,1.318 submit.php,1.65,1.66
vinny at iowaoutdoors.org
vinny at iowaoutdoors.org
Sat May 1 13:57:06 EDT 2004
Update of /var/cvs/geeklog-1.3/public_html
In directory www:/tmp/cvs-serv15756/public_html
Modified Files:
article.php index.php lib-common.php submit.php
Log Message:
Removed DB calls from COM_article to improve performance.
Index: submit.php
===================================================================
RCS file: /var/cvs/geeklog-1.3/public_html/submit.php,v
retrieving revision 1.65
retrieving revision 1.66
diff -C2 -d -r1.65 -r1.66
*** submit.php 28 Feb 2004 11:02:14 -0000 1.65
--- submit.php 1 May 2004 17:57:04 -0000 1.66
***************
*** 292,295 ****
--- 292,299 ----
$A['show_topic_icon'] = 1;
$A['hits'] = 0;
+ $res = DB_query("SELECT username, fullname, photo FROM {$_TABLES['users']} WHERE uid = {$A['uid']}");
+ $A += DB_fetchArray($res);
+ $res = DB_query("SELECT topic, imageurl FROM {$_TABLES['topics']} WHERE tid = '{$A['tid']}'");
+ $A += DB_fetchArray($res);
$retval .= COM_startBlock($LANG12[32])
. COM_article($A,'n')
Index: article.php
===================================================================
RCS file: /var/cvs/geeklog-1.3/public_html/article.php,v
retrieving revision 1.42
retrieving revision 1.43
diff -C2 -d -r1.42 -r1.43
*** article.php 2 Apr 2004 04:42:17 -0000 1.42
--- article.php 1 May 2004 17:57:04 -0000 1.43
***************
*** 90,94 ****
. "/comment.php?sid=$story&pid=$pid&type=$type");
} else {
! $result = DB_query ("SELECT sid,uid,tid,title,introtext,bodytext,hits,comments,featured,draft_flag,show_topic_icon,commentcode,postmode,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon,unix_timestamp(date) AS day FROM {$_TABLES['stories']} WHERE sid = '$story'");
$A = DB_fetchArray ($result);
--- 90,97 ----
. "/comment.php?sid=$story&pid=$pid&type=$type");
} else {
! $result = DB_query ("SELECT STRAIGHT_JOIN s.*, UNIX_TIMESTAMP(s.date) as day, "
! . "u.username, u.fullname, u.photo, 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 (sid = '$story')");
$A = DB_fetchArray ($result);
Index: lib-common.php
===================================================================
RCS file: /var/cvs/geeklog-1.3/public_html/lib-common.php,v
retrieving revision 1.317
retrieving revision 1.318
diff -C2 -d -r1.317 -r1.318
*** lib-common.php 30 Apr 2004 23:36:12 -0000 1.317
--- lib-common.php 1 May 2004 17:57:04 -0000 1.318
***************
*** 369,373 ****
*/
! function COM_article( $A, $index='', $storytpl='storytext.thtml' )
{
global $_TABLES, $mode, $_CONF, $_USER, $LANG01, $LANG05, $LANG11, $_THEME_URL;
--- 369,373 ----
*/
! function COM_article( &$A, $index='', $storytpl='storytext.thtml' )
{
global $_TABLES, $mode, $_CONF, $_USER, $LANG01, $LANG05, $LANG11, $_THEME_URL;
***************
*** 405,418 ****
if( $_CONF['contributedbyline'] == 1 )
{
- $sql = "SELECT username, fullname, photo FROM {$_TABLES['users']} WHERE uid = '{$A['uid']}'";
- $results = DB_query( $sql );
- $U = DB_fetchArray( $results );
-
$article->set_var( 'lang_contributed_by', $LANG01[1] );
$article->set_var( 'contributedby_uid', $A['uid'] );
! $username = $U['username'];
$article->set_var( 'contributedby_user', $username );
! $fullname = $U['fullname'];
if( empty( $fullname ))
{
--- 405,414 ----
if( $_CONF['contributedbyline'] == 1 )
{
$article->set_var( 'lang_contributed_by', $LANG01[1] );
$article->set_var( 'contributedby_uid', $A['uid'] );
! $username = $A['username'];
$article->set_var( 'contributedby_user', $username );
! $fullname = $A['fullname'];
if( empty( $fullname ))
{
***************
*** 433,437 ****
. '/users.php?mode=profile&uid=' . $A['uid'] );
! $photo = $U['photo'];
if( !empty( $photo ))
{
--- 429,433 ----
. '/users.php?mode=profile&uid=' . $A['uid'] );
! $photo = $A['photo'];
if( !empty( $photo ))
{
***************
*** 453,462 ****
if( $_USER['noicons'] != 1 AND $A['show_topic_icon'] == 1 )
{
! $result = DB_query( "SELECT imageurl,topic FROM {$_TABLES['topics']} WHERE tid = '{$A['tid']}'" );
! $T = DB_fetchArray( $result );
!
! $topicname = htmlspecialchars( stripslashes( $T['topic'] ));
$topicurl = $_CONF['site_url'] . '/index.php?topic=' . $A['tid'];
! if( !empty( $T['imageurl'] ))
{
if( isset( $_THEME_URL ))
--- 449,455 ----
if( $_USER['noicons'] != 1 AND $A['show_topic_icon'] == 1 )
{
! $topicname = htmlspecialchars( stripslashes( $A['topic'] ));
$topicurl = $_CONF['site_url'] . '/index.php?topic=' . $A['tid'];
! if( !empty( $A['imageurl'] ))
{
if( isset( $_THEME_URL ))
***************
*** 469,473 ****
}
$topicimage = '<img align="' . $_CONF['article_image_align']
! . '" src="' . $imagebase . $T['imageurl'] . '" alt="'
. $topicname . '" title="' . $topicname . '" border="0">';
$article->set_var( 'story_anchortag_and_image', '<a href="'
--- 462,466 ----
}
$topicimage = '<img align="' . $_CONF['article_image_align']
! . '" src="' . $imagebase . $A['imageurl'] . '" alt="'
. $topicname . '" title="' . $topicname . '" border="0">';
$article->set_var( 'story_anchortag_and_image', '<a href="'
Index: index.php
===================================================================
RCS file: /var/cvs/geeklog-1.3/public_html/index.php,v
retrieving revision 1.56
retrieving revision 1.57
diff -C2 -d -r1.56 -r1.57
*** index.php 28 Feb 2004 16:57:47 -0000 1.56
--- index.php 1 May 2004 17:57:04 -0000 1.57
***************
*** 109,112 ****
--- 109,113 ----
} else {
$U['maxstories'] = $_CONF['limitnews'];
+ /* HELPME: should we check for topic "limitnews" value? */
}
***************
*** 124,152 ****
COM_featuredCheck();
! $sql = "FROM {$_TABLES['stories']} WHERE (date <= NOW()) AND (draft_flag = 0)";
// if a topic was provided only select those stories.
if (!empty($topic)) {
! $sql .= " AND tid = '$topic' ";
} elseif (!$newstories) {
$sql .= " AND frontpage = 1 ";
}
! $sql .= COM_getPermSQL ('AND');
if (!empty($U['aids'])) {
! $sql .= ' ';
! $AIDS = explode(' ',$U['aids']);
! for ($z = 0; $z < sizeof($AIDS); $z++) {
! $sql .= "AND uid != '$AIDS[$z]' ";
! }
}
if (!empty($U['tids'])) {
! $sql .= ' ';
! $TIDS = explode(' ',$U['tids']);
! for ($z = 0; $z < sizeof($TIDS); $z++) {
! $sql .= "AND tid != '$TIDS[$z]' ";
! }
}
--- 125,145 ----
COM_featuredCheck();
! $sql = " (date <= NOW()) AND (draft_flag = 0)";
// if a topic was provided only select those stories.
if (!empty($topic)) {
! $sql .= " AND s.tid = '$topic' ";
} elseif (!$newstories) {
$sql .= " AND frontpage = 1 ";
}
! $sql .= COM_getPermSQL ('AND', 0, 2, 's');
if (!empty($U['aids'])) {
! $sql .= " AND s.uid NOT IN (" . str_replace( ' ', ",", $U['aids'] ) . ") ";
}
if (!empty($U['tids'])) {
! $sql .= " AND s.tid NOT IN ('" . str_replace( ' ', "','", $U['tids'] ) . "') ";
}
***************
*** 155,165 ****
if ($trows > 0) {
$tids = array ();
! for ($i = 0; $i < $trows; $i++) {
! $T = DB_fetchArray ($tresult);
$tids[] = $T['tid'];
}
if (sizeof ($tids) > 0) {
! $sql .= "AND (tid IN ('" . implode ("','", $tids) . "')) ";
}
}
--- 148,158 ----
if ($trows > 0) {
$tids = array ();
! while ( $T = DB_fetchArray ($tresult) ) {
$tids[] = $T['tid'];
}
if (sizeof ($tids) > 0) {
! $sql .= "AND (s.tid IN ('" . implode ("','", $tids) . "')) ";
}
+ /* HELPME -- what happens when sizeof($tids) == 0 ? */
}
***************
*** 171,197 ****
$sql .= "ORDER BY featured DESC, date DESC";
! $result = DB_query ("SELECT *,UNIX_TIMESTAMP(date) AS day " . $sql
! . " LIMIT $offset, $limit");
$nrows = DB_numRows ($result);
! $data = DB_query ("SELECT COUNT(*) AS count " . $sql);
$D = DB_fetchArray ($data);
$num_pages = ceil ($D['count'] / $limit);
! if ($nrows > 0) {
! for ($x = 1; $x <= $nrows; $x++) {
! $A = DB_fetchArray($result);
! if ($A['featured'] == 1) {
! $feature = 'true';
! } elseif (($x == 1) && ($_CONF['showfirstasfeatured'] == 1)) {
! $feature = 'true';
! $A['featured'] = 1;
! }
$display .= COM_article($A,'y');
- if ($A['featured'] == 1) {
- $display .= PLG_showCenterblock (2, $page, $topic);
- }
}
$display .= PLG_showCenterblock (3, $page, $topic); // bottom blocks
--- 164,198 ----
$sql .= "ORDER BY featured DESC, date DESC";
! $result = DB_query ("SELECT STRAIGHT_JOIN s.*, UNIX_TIMESTAMP(s.date) as day, "
! . "u.username, u.fullname, u.photo, 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 . " LIMIT $offset, $limit");
$nrows = DB_numRows ($result);
! $data = DB_query ("SELECT COUNT(*) AS count FROM {$_TABLES['stories']} as s WHERE" . $sql);
$D = DB_fetchArray ($data);
$num_pages = ceil ($D['count'] / $limit);
! if ( $A = DB_fetchArray( $result ) ) {
!
! if ( $_CONF['showfirstasfeatured'] == 1 ) {
! $A['featured'] = 1;
! }
!
! // display first article
! $display .= COM_article($A,'y');
!
! // get plugin center blocks after featured article
! if ($A['featured'] == 1) {
! $display .= PLG_showCenterblock (2, $page, $topic);
! }
!
! // get reamaining stories
! while ( $A = DB_fetchArray($result) ) {
$display .= COM_article($A,'y');
}
+ // get plugin center blocks that follow articles
$display .= PLG_showCenterblock (3, $page, $topic); // bottom blocks
More information about the geeklog-cvs
mailing list