[Fusionforge-commits] r8094 - trunk/gforge/www/export

Roland Mas lolando at libremir.placard.fr.eu.org
Thu Sep 3 21:22:50 CEST 2009


Author: lolando
Date: 2009-09-03 21:22:50 +0200 (Thu, 03 Sep 2009)
New Revision: 8094

Modified:
   trunk/gforge/www/export/forum.php
   trunk/gforge/www/export/rss20_activity.php
   trunk/gforge/www/export/rss20_newreleases.php
   trunk/gforge/www/export/rss20_news.php
   trunk/gforge/www/export/rss20_projects.php
   trunk/gforge/www/export/rss_sfnewreleases.php
   trunk/gforge/www/export/rss_sfnews.php
   trunk/gforge/www/export/rss_sfprojects.php
   trunk/gforge/www/export/trove_tree.php
Log:
Ongoing migration to db_query_params()

Modified: trunk/gforge/www/export/forum.php
===================================================================
--- trunk/gforge/www/export/forum.php	2009-09-03 18:30:16 UTC (rev 8093)
+++ trunk/gforge/www/export/forum.php	2009-09-03 19:22:50 UTC (rev 8094)
@@ -20,15 +20,13 @@
 $group_id = getIntFromRequest('group_id');
 
 // group_id must be specified
-$res_grp = db_query_params ('
-	SELECT group_id,group_name
-	FROM groups 
+$res_grp = db_query_params ('SELECT group_id,group_name
+	FROM groups
 	WHERE is_public=1
 	AND status=$1
-	AND group_id=$2
-',
-			array('A',
-				$group_id)) ;
+	AND group_id=$2',
+			    array('A',
+				  $group_id)) ;
 
 if (db_numrows($res_grp) < 1) {
 	print 'ERROR: This URL must be called with a valid group_id parameter';
@@ -42,24 +40,22 @@
 ';
 print '<group name="'.$row_grp['group_name'].'">';
 
-$res_forum = db_query("
-	SELECT group_forum_id,forum_name
-	FROM forum_group_list 
-	WHERE group_id='$group_id'
-");
+$res_forum = db_query_params ('SELECT group_forum_id,forum_name
+	FROM forum_group_list
+	WHERE group_id=$1',
+			      array ($group_id));
 
 while ($row_forum = db_fetch_array($res_forum)) {
 	print ' <forum name="'.$row_forum['forum_name'].'">'."\n";
 
-	$res_post = db_query("
-		SELECT forum.msg_id AS msg_id,forum.subject AS subject,
+	$res_post = db_query_params ('SELECT forum.msg_id AS msg_id,forum.subject AS subject,
 			forum.body AS body,forum.date AS date,
 			users.user_name AS user_name,
 			users.realname AS realname
-		FROM forum,users 
+		FROM forum,users
 		WHERE forum.posted_by=users.user_id
-		AND forum.group_forum_id='".$row_forum['group_forum_id']."'
-	");
+		AND forum.group_forum_id=$1',
+				     array ($row_forum['group_forum_id']));
 
 
 	// ## item outputs

Modified: trunk/gforge/www/export/rss20_activity.php
===================================================================
--- trunk/gforge/www/export/rss20_activity.php	2009-09-03 18:30:16 UTC (rev 8093)
+++ trunk/gforge/www/export/rss20_activity.php	2009-09-03 19:22:50 UTC (rev 8094)
@@ -37,15 +37,17 @@
 $url = util_make_url ('/');
 
 if ($group_id) {
-	$where = "group_id=$group_id and is_public=1";
-	$query = "SELECT group_name FROM groups WHERE $where";
-	$res = db_query($query,1);
+	$res = db_query_params ('SELECT group_name FROM groups WHERE group_id=$1 and is_public=1',
+				array($group_id),
+				1);
 	$row = db_fetch_array($res);
 	$title = $row['group_name'];
 	$link = "?group_id=$group_id";
 	$description = " of ".$row['group_name'];
-	$querywm =  "SELECT users.user_name,users.realname FROM user_group,users WHERE group_id=$group_id AND admin_flags='A' AND users.user_id=user_group.user_id ORDER BY users.add_date";
-	$reswm = db_query($querywm,1);
+
+	$reswm = db_query_params ('SELECT users.user_name,users.realname FROM user_group,users WHERE group_id=$group_id AND admin_flags=$1 AND users.user_id=user_group.user_id ORDER BY users.add_date',
+				  array('A'),
+				  1);
 	if ($rowwm = db_fetch_array($reswm)) {
 		$webmaster = $rowwm['user_name']."@".$GLOBALS['sys_users_host']." (".$rowwm['realname'].")";
 	} else {
@@ -68,9 +70,11 @@
 	print "  <docs>http://blogs.law.harvard.edu/tech/rss</docs>\n";
 	print "  <generator>".$GLOBALS['sys_name']." RSS generator</generator>\n";
 
-	$sql="SELECT * FROM activity_vw WHERE activity_date BETWEEN '".(time()-(30*86400))."' AND '".time()."'
-	AND group_id='$group_id' ORDER BY activity_date DESC";
-	$res = db_query($sql, $limit);
+	$res = db_query_params ('SELECT * FROM activity_vw WHERE activity_date BETWEEN $1 AND $2 AND group_id=$3 ORDER BY activity_date DESC',
+				array(time() - 30*86400,
+				      time(),
+				      $group_id),
+				$limit);
 
 	// ## item outputs
 	while ($arr = db_fetch_array($res)) {

Modified: trunk/gforge/www/export/rss20_newreleases.php
===================================================================
--- trunk/gforge/www/export/rss20_newreleases.php	2009-09-03 18:30:16 UTC (rev 8093)
+++ trunk/gforge/www/export/rss20_newreleases.php	2009-09-03 19:22:50 UTC (rev 8094)
@@ -20,13 +20,14 @@
 if ($group_id) {
 	$where = "frs_package.group_id=$group_id AND ";
 	$res = db_query_params ('SELECT group_name FROM groups WHERE group_id=$1 AND is_public=1',
-			array($group_id)) ;
+				array ($group_id)) ;
 	$row = db_fetch_array($res);
 	$title = ": ".$row['group_name']." - ";
 	$link = "/project/showfiles.php?group_id=$group_id";
 	$description = " of ".$row['group_name'];
-	$querywm =  "SELECT users.user_name,users.realname FROM user_group,users WHERE group_id=$group_id AND admin_flags='A' AND users.user_id=user_group.user_id ORDER BY users.add_date";
-	$reswm = db_query($querywm,1);
+	$reswm = db_query_params ('SELECT users.user_name,users.realname FROM user_group,users WHERE group_id=$1 AND admin_flags=$2 AND users.user_id=user_group.user_id ORDER BY users.add_date',
+				  array($group_id,
+					'A'));
 	if ($rowwm = db_fetch_array($reswm)) {
 	  $webmaster = $rowwm['user_name']."@".$GLOBALS['sys_users_host']." (".$rowwm['realname'].")";
 	} else {
@@ -34,7 +35,7 @@
 	}
 } else {
 	$where = "";
-    $title = "";
+	$title = "";
 	$link = "/new/";
 	$description = "";
 	$webmaster = $GLOBALS['sys_admin_email'];

Modified: trunk/gforge/www/export/rss20_news.php
===================================================================
--- trunk/gforge/www/export/rss20_news.php	2009-09-03 18:30:16 UTC (rev 8093)
+++ trunk/gforge/www/export/rss20_news.php	2009-09-03 19:22:50 UTC (rev 8094)
@@ -17,14 +17,18 @@
 
 if ($group_id) {
 	$where = "AND g.group_id=$group_id";
-	$query = "SELECT group_name FROM groups WHERE group_id=$group_id AND is_public=1";
-	$res = db_query($query,1);
+
+	$res = db_query_params ('SELECT group_name FROM groups WHERE group_id=$1 AND is_public=1',
+				array($group_id),
+				1);
 	$row = db_fetch_array($res);
 	$title = ": ".$row['group_name']." - ";
 	$link = "?group_id=$group_id";
 	$description = " of ".$row['group_name'];
-	$querywm =  "SELECT users.user_name,users.realname FROM user_group,users WHERE group_id=$group_id AND admin_flags='A' AND users.user_id=user_group.user_id ORDER BY users.add_date";
-	$reswm = db_query($querywm,1);
+
+	$reswm = db_query_params ('SELECT users.user_name,users.realname FROM user_group,users WHERE group_id=$group_id AND admin_flags=$1 AND users.user_id=user_group.user_id ORDER BY users.add_date',
+				  array('A'),
+				  1);
 	if ($rowwm = db_fetch_array($reswm)) {
 	  $webmaster = $rowwm['user_name']."@".$GLOBALS['sys_users_host']." (".$rowwm['realname'].")";
 	} else {

Modified: trunk/gforge/www/export/rss20_projects.php
===================================================================
--- trunk/gforge/www/export/rss20_projects.php	2009-09-03 18:30:16 UTC (rev 8093)
+++ trunk/gforge/www/export/rss20_projects.php	2009-09-03 19:22:50 UTC (rev 8094)
@@ -14,11 +14,9 @@
 
 $limit = getIntFromRequest('limit', 10);
 
-$res = db_query(
-	 'SELECT group_id,group_name,unix_group_name,homepage,short_description,register_time '
-	.'FROM groups '
-	.'WHERE is_public=1 AND status=\'A\' '
-        .'ORDER BY group_id',$limit);
+$res = db_query_params ('SELECT group_id,group_name,unix_group_name,homepage,short_description,register_time FROM groups WHERE is_public=1 AND status=$1 ORDER BY group_id',
+			array ('A'),
+			$limit);
 
 //rss20_dump_project_result_set($res,$GLOBALS['sys_default_name'].' Full Project Listing');
 // quick and dirty fix

Modified: trunk/gforge/www/export/rss_sfnewreleases.php
===================================================================
--- trunk/gforge/www/export/rss_sfnewreleases.php	2009-09-03 18:30:16 UTC (rev 8093)
+++ trunk/gforge/www/export/rss_sfnewreleases.php	2009-09-03 19:22:50 UTC (rev 8094)
@@ -23,7 +23,7 @@
 <rss version="0.91">
 ';
 
-$res=db_query("SELECT 
+$res=db_query_params ('SELECT 
 					groups.group_id,
 					groups.group_name,
 					groups.unix_group_name,
@@ -37,11 +37,13 @@
 					groups 
 				WHERE 
 					news_bytes.group_id=groups.group_id 
-					AND groups.status='A'
+					AND groups.status=$1
 					AND groups.is_public = 1
 				ORDER BY 
 					post_date 
-				DESC",($limit * 3));
+				DESC',
+		      array('A'),
+		      $limit * 3);
 
 
 // ## one time output

Modified: trunk/gforge/www/export/rss_sfnews.php
===================================================================
--- trunk/gforge/www/export/rss_sfnews.php	2009-09-03 18:30:16 UTC (rev 8093)
+++ trunk/gforge/www/export/rss_sfnews.php	2009-09-03 19:22:50 UTC (rev 8094)
@@ -16,7 +16,9 @@
 
 $group_id = getIntFromRequest('group_id');
 $limit = getIntFromRequest('limit', 10);
-if ($limit > 100) $limit = 100;
+if (($limit > 100) || ($limit <= 0)) {
+	$limit = 100;
+}
 
 header("Content-Type: text/xml; charset=utf-8");
 print '<?xml version="1.0" encoding="UTF-8"?>
@@ -29,47 +31,61 @@
 	xmlns:syn="http://purl.org/rss/1.0/modules/syndication/"
 	xmlns:admin="http://webns.net/mvcb/" >';
 
-if ($group_id) {
-	$where = " AND g.group_id='$group_id'";
-} else {
-	$where = " AND is_approved=1";
-}
-$sql = "SELECT forum_id,summary,post_date,details,g.group_id,g.group_name,u.realname 
-	FROM news_bytes, groups g,users u 
+function getres ($gid, $l) {
+	if ($id) {
+		$res = db_query_params ('SELECT forum_id,summary,post_date,details,g.group_id,g.group_name,u.realname
+	FROM news_bytes, groups g,users u
 	WHERE news_bytes.group_id=g.group_id
 	AND u.user_id=news_bytes.submitted_by
-	AND g.is_public='1'
-	AND g.status='A'
-	$where
-	order by post_date desc";
-	$res = db_query($sql, $limit);
+	AND g.is_public=1
+	AND g.status=$1
+	AND g.group_id=$2
+	ORDER BY post_date desc',
+					array('A',
+					      $gid),
+					$l);
+	} else {
+		$res = db_query_params ('SELECT forum_id,summary,post_date,details,g.group_id,g.group_name,u.realname
+	FROM news_bytes, groups g,users u
+	WHERE news_bytes.group_id=g.group_id
+	AND u.user_id=news_bytes.submitted_by
+	AND g.is_public=1
+	AND g.status=$1
+	AND is_approved=1
+	ORDER BY post_date desc',
+					array('A'),
+					$l);
+	}
+	return $res ;
+}
 
-print "\n <channel rdf:about=".'"'."http://$GLOBALS[sys_default_domain]/export/rss_sfnews.php".'"'.">\n";
-$grsql = "SELECT group_name from groups where group_id='.$group_id'";
-$grres = db_query($sql,$limit);
-$grrow = db_fetch_array($grres);
+print "\n <channel rdf:about=\"".util_make_url ('/export/rss_sfnews.php')."\">\n";
 
 print "  <title>".$GLOBALS['sys_name']." Project News</title>\n";
-print "  <link>http://$GLOBALS[sys_default_domain]</link>\n";
+print "  <link>".util_make_url ('/')."</link>\n";
 print "  <description>".$GLOBALS['sys_name']." Project News Highlights</description>\n";
 // ## item outputs
 print " <items>\n";
 print " <rdf:Seq>\n";
+
+$res = getres ($group_id, $limit) ;
 while ($row = db_fetch_array($res)) {
-	print " <rdf:li rdf:resource=".'"'."http://$GLOBALS[sys_default_domain]/forum/forum.php?forum_id=$row[forum_id]".'"'." />\n";
+	print " <rdf:li rdf:resource=\"".util_make_url ('/forum/forum.php?forum_id='.$row[forum_id])."\" />\n";
 }
+
 print " </rdf:Seq>\n";
 print " </items>\n";
 print " </channel>\n";
-$res = db_query($sql, $limit);
+
+$res = getres ($group_id, $limit) ;
 while ($row = db_fetch_array($res)) {
-	print "\n <item rdf:about=".'"'."http://$GLOBALS[sys_default_domain]/forum/forum.php?forum_id=$row[forum_id]".'"'.">\n";
+	print "\n <item rdf:about=\"".util_make_url ('/forum/forum.php?forum_id='.$row[forum_id])."\">\n";
 	print "   <title>".htmlspecialchars($row['summary'])."</title>\n";
 	// if news group, link is main page
 	if ($row['group_id'] != $sys_news_group) {
-		print "   <link>http://$GLOBALS[sys_default_domain]/forum/forum.php?forum_id=$row[forum_id]</link>\n";
+		print "   <link>".util_make_url ('/forum/forum.php?forum_id='.$row[forum_id])."</link>\n";
 	} else {
-		print "   <link>http://$GLOBALS[sys_default_domain]/</link>\n";
+		print "   <link>".util_make_url ('/')."</link>\n";
 	}
 	print "   <description>".rss_description($row['details'])."</description>\n";
 	print "   <dc:subject>".$row['group_name']."</dc:subject>\n";

Modified: trunk/gforge/www/export/rss_sfprojects.php
===================================================================
--- trunk/gforge/www/export/rss_sfprojects.php	2009-09-03 18:30:16 UTC (rev 8093)
+++ trunk/gforge/www/export/rss_sfprojects.php	2009-09-03 19:22:50 UTC (rev 8094)
@@ -15,7 +15,9 @@
 require_once $gfwww.'export/rss_utils.inc';
 
 $showall = getIntFromRequest('showall', 0);
-if ($showall == 0) {
+if ($showall) {
+	$limit = 0 ;
+} else {
 	$limit = getIntFromRequest('limit', 10);
 	if ($limit > 100) $limit = 100;
 }
@@ -25,26 +27,14 @@
 <!DOCTYPE rss SYSTEM "http://my.netscape.com/publish/formats/rss-0.91.dtd">
 <rss version="0.91">
 ';
-$sql = "SELECT 
-		group_id,
-		group_name,
-		unix_group_name,
-		homepage,
-		short_description 
-	FROM 
-		groups 
-	WHERE 
-		is_public=1 
-	AND 
-		status='A' 
-    ORDER BY 
-		group_id DESC" ;
 
-if ($showall) {
-	$res = db_query ($sql);
-} else {
-	$res = db_query ($sql, $limit);
-}
+$res = db_query_params ('SELECT group_id,group_name,unix_group_name,homepage,short_description
+	FROM groups
+	WHERE is_public=1
+	AND status=$1
+        ORDER BY group_id DESC',
+			array('A'),
+			$limit);
 
 rss_dump_project_result_set($res,$GLOBALS['sys_name'].' Full Project Listing');
 ?>

Modified: trunk/gforge/www/export/trove_tree.php
===================================================================
--- trunk/gforge/www/export/trove_tree.php	2009-09-03 18:30:16 UTC (rev 8093)
+++ trunk/gforge/www/export/trove_tree.php	2009-09-03 19:22:50 UTC (rev 8094)
@@ -16,7 +16,7 @@
 
 header("Content-Type: text/plain");
 print("<?xml version=\"1.0\"?>
-<!DOCTYPE trove-tree SYSTEM \"http://$sys_default_domain/export/trove_tree_0.1.dtd\">
+<!DOCTYPE trove-tree SYSTEM ".util_make_url ('/export/trove_tree_0.1.dtd')."\">
 <trove-tree>\n");
 
 
@@ -31,11 +31,8 @@
 
 function dump_subtree($root) {
         global $level;
-	$res = db_query("
-		SELECT *
-		FROM trove_cat
-		WHERE parent='$root'
-	", -1, 0, SYS_DB_TROVE);
+	$res = db_query_params ('SELECT * FROM trove_cat WHERE parent=$1',
+				array ($root));
 
         if (db_numrows($res)==0) {
 		// leaf category
@@ -58,10 +55,14 @@
         return true;
 }
 
-
 dump_subtree(0);
 
 print("  </category>\n");
 print("</trove-tree>\n");
 
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
 ?>




More information about the Fusionforge-commits mailing list