[Fusionforge-commits] FusionForge branch 6.1 updated. v6.1beta1-17-g0283a7e

Franck Villaume nerville at libremir.placard.fr.eu.org
Tue Dec 26 12:55:16 CET 2017


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, 6.1 has been updated
       via  0283a7e3fba3cd58836abe20a7a115a4e9eee947 (commit)
       via  19f4dec796bb8d4a7bf799501488792387dd2790 (commit)
      from  2873182e0b3e2f4c36b763d29808e861e34271ca (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=0283a7e3fba3cd58836abe20a7a115a4e9eee947

commit 0283a7e3fba3cd58836abe20a7a115a4e9eee947
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Tue Dec 26 12:54:48 2017 +0100

    inject-*.php: add control on arguments, clean-up

diff --git a/src/bin/inject-files.php b/src/bin/inject-files.php
index 42dc702..97c5be4 100755
--- a/src/bin/inject-files.php
+++ b/src/bin/inject-files.php
@@ -2,6 +2,7 @@
 <?php
 /**
  * Copyright 2009, Roland Mas
+ * Copyright 2017, Franck Villaume - TrivialDev
  *
  * This file is part of FusionForge. FusionForge is free software;
  * you can redistribute it and/or modify it under the terms of the
@@ -19,14 +20,6 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-require (dirname (__FILE__).'/../common/include/env.inc.php');
-require_once $gfcommon.'include/pre.php';
-require_once $gfcommon.'frs/FRSPackage.class.php';
-require_once $gfcommon.'frs/FRSRelease.class.php';
-require_once $gfcommon.'frs/FRSFile.class.php';
-
-db_begin ();
-
 /*
  * Line format:
  * project:packagename:releasename:filepath:notes:changes:type:processor
@@ -49,79 +42,97 @@ db_begin ();
  9999 | Other
 */
 
-$f = fopen ('files.txt', 'r') ;
-while (! feof ($f)) {
-	$l = trim (fgets ($f, 1024)) ;
-	if ($l == "") { continue ; } ;
-	$array = explode (':', $l) ;
-	$projectname = $array[0] ;
-	$packagename = $array[1] ;
-	$releasename = $array[2] ;
-	$filepath = $array[3] ;
-	$notes = $array[4] ;
-	$changes = $array[5] ;
-	$typeid = $array[6] ;
-	$processorid = $array[7] ;
+require (dirname (__FILE__).'/../common/include/env.inc.php');
+require_once $gfcommon.'include/pre.php';
+require_once $gfcommon.'frs/FRSPackage.class.php';
+require_once $gfcommon.'frs/FRSRelease.class.php';
+require_once $gfcommon.'frs/FRSFile.class.php';
 
-	$admin = user_get_object_by_name ('admin') ;
-	session_set_new ($admin->getID ()) ;
+if (count($argv) != 2) {
+	echo "Usage: .../inject-files.php files.txt\n";
+	exit(1);
+}
+
+if (!is_file('files.txt')) {
+	echo "Cannot open files.txt\n";
+	exit(1);
+}
 
-	$g = group_get_object_by_name ($projectname);
+$f = fopen('files.txt', 'r');
+db_begin();
+
+while (!feof($f)) {
+	$l = trim (fgets($f, 1024));
+	if ($l == "") { continue; }
+	$array = explode (':', $l);
+	$projectname = $array[0];
+	$packagename = $array[1];
+	$releasename = $array[2];
+	$filepath = $array[3];
+	$notes = $array[4];
+	$changes = $array[5];
+	$typeid = $array[6];
+	$processorid = $array[7];
+
+	$admin = user_get_object_by_name('admin');
+	session_set_new($admin->getID());
+
+	$g = group_get_object_by_name($projectname);
 	if (! $g) {
-		print "Error: invalid group\n" ;
-		db_rollback () ;
-		exit (1) ;
+		print "Error: invalid group\n";
+		db_rollback();
+		exit(1);
 	}
 
-	$packages = get_frs_packages ($g) ;
+	$packages = get_frs_packages($g);
 	$package = false ;
 	if ($packages) {
 		foreach ($packages as $cur) {
 			if ($cur->getName () == $packagename) {
-				$package = $cur ;
-				break ;
+				$package = $cur;
+				break;
 			}
 		}
 	}
 	if (!$package) {
-		$package = new FRSPackage ($g) ;
-		$r = $package->create ($packagename) ;
+		$package = new FRSPackage($g);
+		$r = $package->create($packagename);
 	}
 	if (!$r || !$package) {
-		print "Error when creating FRS package\n" ;
-		db_rollback () ;
-		exit (1) ;
+		print "Error when creating FRS package\n";
+		db_rollback();
+		exit(1);
 	}
 
-	$releases = $package->getReleases () ;
-	$release = false ;
+	$releases = $package->getReleases();
+	$release = false;
 	if ($releases) {
 		foreach ($releases as $cur) {
 			if ($cur->getName () == $releasename) {
-				$release = $cur ;
+				$release = $cur;
 				break ;
 			}
 		}
 	}
 	if (!$release) {
-		$release = new FRSRelease ($package) ;
-		$r = $release->create ($releasename, $notes, $changes, false) ;
+		$release = new FRSRelease($package);
+		$r = $release->create($releasename, $notes, $changes, false);
 	}
 	if (!$r || !$release) {
 		print "Error when creating FRS release\n" ;
-		db_rollback () ;
-		exit (1) ;
+		db_rollback();
+		exit(1);
 	}
 
-	$file = new FRSFile ($release) ;
-	$pathcomponents = explode ('/', $filepath) ;
-	$filename = $pathcomponents[count($pathcomponents)-1] ;
-	$r = $file->create ($filename, $filepath, $typeid, $processorid) ;
+	$file = new FRSFile($release);
+	$pathcomponents = explode('/', $filepath);
+	$filename = $pathcomponents[count($pathcomponents)-1];
+	$r = $file->create($filename, $filepath, $typeid, $processorid);
 
 	if (!$r) {
-		print "Error when creating FRS file\n" ;
-		db_rollback () ;
-		exit (1) ;
+		print "Error when creating FRS file\n";
+		db_rollback();
+		exit(1);
 	}
 }
 fclose ($f);
diff --git a/src/bin/inject-groups.php b/src/bin/inject-groups.php
index 980183e..8929b72 100755
--- a/src/bin/inject-groups.php
+++ b/src/bin/inject-groups.php
@@ -2,6 +2,7 @@
 <?php
 /**
  * Copyright 2009, Roland Mas
+ * Copyright 2017, Franck Villaume
  *
  * This file is part of FusionForge. FusionForge is free software;
  * you can redistribute it and/or modify it under the terms of the
@@ -18,32 +19,40 @@
  * with FusionForge; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
-
-require (dirname (__FILE__).'/../common/include/env.inc.php');
-require_once $gfcommon.'include/pre.php';
-
-db_begin ();
-
 /*
  * Line format:
  * unixname:fullname:description:username
  * username is login of admin user
  * Beware of colons in text fields (fullname, description)!
 */
+require (dirname (__FILE__).'/../common/include/env.inc.php');
+require_once $gfcommon.'include/pre.php';
+
+if (count($argv) != 2) {
+	echo "Usage: .../inject-groups.php groups.txt\n";
+	exit(1);
+}
+
+if (!is_file('groups.txt')) {
+	echo "Cannot open groups.txt\n";
+	exit(1);
+}
+
+$f = fopen('groups.txt', 'r');
+db_begin();
 
-$f = fopen ('groups.txt', 'r') ;
 while (! feof ($f)) {
-	$l = trim (fgets ($f, 1024)) ;
-	if ($l == "") { continue ; } ;
-	$array = explode (':', $l) ;
+	$l = trim (fgets ($f, 1024));
+	if ($l == "") { continue ; }
+	$array = explode(':', $l);
 	$unixname = $array[0];
 	$fullname = $array[1];
 	$description = $array[2];
 	$username = $array[3];
 
 	$u = user_get_object_by_name($username);
-	if (! $u) {
-		print "Error: invalid user\n" ;
+	if (!$u) {
+		print "Error: invalid user\n";
 		db_rollback();
 		exit(1);
 	}
@@ -52,24 +61,24 @@ while (! feof ($f)) {
 	$r = $g->create($u, $fullname, $unixname, $description, 'Project injected into the database by inject-groups.php', 'shell', 'scm', false);
 
 	if (!$r) {
-		print "Error: ". $g->getErrorMessage () . "\n" ;
-		db_rollback () ;
-		exit (1) ;
+		print "Error: ".$g->getErrorMessage()."\n";
+		db_rollback();
+		exit(1);
 	}
 
-	$admin = user_get_object_by_name ('admin') ;
-	session_set_new ($admin->getID ()) ;
-	$r = $g->approve ($admin) ;
+	$admin = user_get_object_by_name('admin');
+	session_set_new($admin->getID());
+	$r = $g->approve($admin);
 	if (!$r) {
-		print "Error: ". $g->getErrorMessage () . "\n" ;
-		db_rollback () ;
-		exit (1) ;
+		print "Error: ".$g->getErrorMessage()."\n";
+		db_rollback();
+		exit(1);
 	}
 }
 fclose ($f);
 
 // If everything went well so far, we can commit
-db_commit () ;
+db_commit();
 
 // Local Variables:
 // mode: php
diff --git a/src/bin/inject-users.php b/src/bin/inject-users.php
index 4c7f3a1..55cfea4 100755
--- a/src/bin/inject-users.php
+++ b/src/bin/inject-users.php
@@ -2,6 +2,7 @@
 <?php
 /**
  * Copyright 2009, Roland Mas
+ * Copyright 2017, Franck Villaume - TrivialDev
  *
  * This file is part of FusionForge. FusionForge is free software;
  * you can redistribute it and/or modify it under the terms of the
@@ -18,6 +19,13 @@
  * with FusionForge; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
+/*
+ * Line format:
+ * login:email:fname:lname:password
+ * password is cleartext
+ * login might be optional if sys_require_unique_email is true
+*/
+
 
 require (dirname (__FILE__).'/../common/include/env.inc.php');
 require_once $gfcommon.'include/pre.php';
@@ -27,44 +35,48 @@ if (!$themeId) {
 	print "Error: missing theme id";
 	exit(1);
 }
-db_begin ();
 
-/*
- * Line format:
- * login:email:fname:lname:password
- * password is cleartext
- * login might be optional if sys_require_unique_email is true
-*/
+if (count($argv) != 2) {
+	echo "Usage: .../inject-users.php users.txt\n";
+	exit(1);
+}
+
+if (!is_file('users.txt')) {
+	echo "Cannot open users.txt\n";
+	exit(1);
+}
+
+$f = fopen('users.txt', 'r');
+db_begin();
 
-$f = fopen ('users.txt', 'r') ;
 while (! feof ($f)) {
-	$l = trim (fgets ($f, 1024)) ;
-	if ($l == "") { continue ; } ;
-	$array = explode (':', $l, 5) ;
-	$login = $array[0] ;
-	$email = $array[1] ;
-	$fname = $array[2] ;
-	$lname = $array[3] ;
-	$password = $array[4] ;
+	$l = trim (fgets ($f, 1024));
+	if ($l == "") { continue ; }
+	$array = explode (':', $l, 5);
+	$login = $array[0];
+	$email = $array[1];
+	$fname = $array[2];
+	$lname = $array[3];
+	$password = $array[4];
 
-	$u = new FFUser () ;
+	$u = new FFUser();
 
-	$r = $u->create ($login, $fname, $lname, $password, $password, $email,
+	$r = $u->create($login, $fname, $lname, $password, $password, $email,
 			 1, 0, 1, 'UTC', '', '', $themeId,
 			 'shell', '', '', '', '', '', 'US', false);
 
 	if (!$r) {
-		print "Error: ". $u->getErrorMessage () . "\n" ;
-		db_rollback () ;
-		exit (1) ;
+		print "Error: ".$u->getErrorMessage()."\n";
+		db_rollback();
+		exit(1);
 	}
 
-	$u->setStatus ('A') ;
+	$u->setStatus('A');
 }
 fclose ($f);
 
 // If everything went well so far, we can commit
-db_commit () ;
+db_commit();
 
 // Local Variables:
 // mode: php

https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=19f4dec796bb8d4a7bf799501488792387dd2790

commit 19f4dec796bb8d4a7bf799501488792387dd2790
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Tue Dec 26 12:54:23 2017 +0100

    forge_set_password: clean-up

diff --git a/src/bin/forge_set_password b/src/bin/forge_set_password
index fea6bfd..a731dc1 100755
--- a/src/bin/forge_set_password
+++ b/src/bin/forge_set_password
@@ -29,19 +29,16 @@ if (count ($argv) == 3) {
 	$p = $argv[2] ;
 	$user = user_get_object_by_name ($u) ;
 	if (!$user || $user->isError()) {
-		echo "Can't find this user...
-" ;
-		exit (1) ;
+		echo "Can't find this user...\n";
+		exit(1);
 	}
 	if (!$user->setPasswd ($p)) {
-		echo "An error occurred.  Weak password?
-" ;
-		exit (1) ;
+		echo "An error occurred.  Weak password?\n";
+		exit(1);
 	}
 } else {
-	echo "Usage: .../forge_set_password <username> <password>
-" ;
-	exit (1) ;
+	echo "Usage: .../forge_set_password <username> <password>\n";
+	exit(1);
 }
 
 // Local Variables:

-----------------------------------------------------------------------

Summary of changes:
 src/bin/forge_set_password |  15 +++----
 src/bin/inject-files.php   | 109 +++++++++++++++++++++++++--------------------
 src/bin/inject-groups.php  |  53 +++++++++++++---------
 src/bin/inject-users.php   |  58 ++++++++++++++----------
 4 files changed, 132 insertions(+), 103 deletions(-)


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list