[geeklog-cvs] geeklog-1.3/public_html/admin user.php,1.79,1.80
dhaun at iowaoutdoors.org
dhaun at iowaoutdoors.org
Wed Aug 11 14:14:45 EDT 2004
Update of /var/cvs/geeklog-1.3/public_html/admin
In directory www:/tmp/cvs-serv11717/public_html/admin
Modified Files:
user.php
Log Message:
ntroduced a 'data' directory ($_CONF['path_data']) and use it for the batch user import, as Geeklog's base directory may not be writable on some setups (bug #77)
Index: user.php
===================================================================
RCS file: /var/cvs/geeklog-1.3/public_html/admin/user.php,v
retrieving revision 1.79
retrieving revision 1.80
diff -C2 -d -r1.79 -r1.80
*** user.php 24 Jul 2004 13:05:06 -0000 1.79
--- user.php 11 Aug 2004 18:14:42 -0000 1.80
***************
*** 457,461 ****
* This function allows the administrator to import batches of users
*
! * $file string file to import
*
*/
--- 457,462 ----
* This function allows the administrator to import batches of users
*
! * @param string $file file to import
! * @return string HTML with success or error message
*
*/
***************
*** 468,501 ****
$verbose_import = true;
// First, upload the file
! require_once($_CONF['path_system'] . 'classes/upload.class.php');
! $upload = new upload();
! $upload->setPath($_CONF['path']);
! $upload->setAllowedMimeTypes(array('text/plain'=>'.txt'));
! $upload->setFileNames('user_import_file.txt');
! if ($upload->uploadFiles()) {
// Good, file got uploaded, now install everything
! $thefile = current($HTTP_POST_FILES);
! $filename = $_CONF['path'] . 'user_import_file.txt';
} else {
// A problem occurred, print debug information
! print 'ERRORS<br>';
! $upload->printErrors();
! exit;
! }
! $retval = '';
! $handle = @fopen($filename,'r');
if (empty ($handle)) {
! return $LANG28[34];
}
// Following variables track import processing statistics
$successes = 0;
$failures = 0;
! while ($user1 = fgets($handle,4096)) {
! $user = rtrim($user1);
list ($full_name, $u_name, $email) = split ("\t", $user);
--- 469,516 ----
$verbose_import = true;
+ $retval = '';
+
// First, upload the file
! require_once ($_CONF['path_system'] . 'classes/upload.class.php');
! $upload = new upload ();
! $upload->setPath ($_CONF['path_data']);
! $upload->setAllowedMimeTypes (array ('text/plain' => '.txt'));
! $upload->setFileNames ('user_import_file.txt');
! if ($upload->uploadFiles ()) {
// Good, file got uploaded, now install everything
! $thefile = current ($HTTP_POST_FILES);
! $filename = $_CONF['path_data'] . 'user_import_file.txt';
} else {
// A problem occurred, print debug information
! $retval = COM_siteHeader ('menu', $LANG28[22]);
! $retval .= COM_startBlock ($LANG28[24], '',
! COM_getBlockTemplate ('_msg_block', 'header'));
! $retval .= $upload->printErrors ();
! $retval .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
! return $retval;
! }
! $handle = @fopen ($filename, 'r');
if (empty ($handle)) {
! $retval = COM_siteHeader ('menu', $LANG28[22]);
! $retval .= COM_startBlock ($LANG28[24], '',
! COM_getBlockTemplate ('_msg_block', 'header'));
! $retval .= $LANG28[34];
! $retval .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
!
! return $retval;
}
+ $retval .= COM_siteHeader ('menu', $LANG28[22]);
+ $retval .= COM_startBlock ($LANG28[31], '',
+ COM_getBlockTemplate ('_admin_block', 'header'));
+
// Following variables track import processing statistics
$successes = 0;
$failures = 0;
! while ($user1 = fgets ($handle, 4096)) {
! $user = rtrim ($user1);
list ($full_name, $u_name, $email) = split ("\t", $user);
***************
*** 506,510 ****
if ($verbose_import) {
$retval .="<br><b>Working on username=$u_name, fullname=$full_name, and email=$email</b><br>\n";
! COM_errorLog("Working on username=$u_name, fullname=$full_name, and email=$email",1);
}
--- 521,525 ----
if ($verbose_import) {
$retval .="<br><b>Working on username=$u_name, fullname=$full_name, and email=$email</b><br>\n";
! COM_errorLog ("Working on username=$u_name, fullname=$full_name, and email=$email",1);
}
***************
*** 521,528 ****
if ($ucount == 0 && ecount == 0) {
// user doesn't already exist
! $regdate = strftime('%Y-%m-%d %H:%M:%S',time());
// Create user record
! DB_query("INSERT INTO {$_TABLES['users']} (username,fullname,email,regdate) VALUES ('$userName','$fullName','$emailAddr','$regdate')");
$uid = DB_getItem($_TABLES['users'],'uid',"username = '$userName'");
--- 536,543 ----
if ($ucount == 0 && ecount == 0) {
// user doesn't already exist
! $regdate = strftime ('%Y-%m-%d %H:%M:%S', time ());
// Create user record
! DB_query ("INSERT INTO {$_TABLES['users']} (username,fullname,email,regdate) VALUES ('$userName','$fullName','$emailAddr','$regdate')");
$uid = DB_getItem($_TABLES['users'],'uid',"username = '$userName'");
***************
*** 566,571 ****
} // end while
! fclose($handle);
! unlink($filename);
$report = $LANG28[32];
--- 581,586 ----
} // end while
! fclose ($handle);
! unlink ($filename);
$report = $LANG28[32];
***************
*** 574,577 ****
--- 589,595 ----
$retval .= '<p>' . $report;
+ $retval .= COM_endBlock (COM_getBlockTemplate ('_admin_block', 'footer'));
+ $retval .= COM_siteFooter ();
+
return $retval;
}
***************
*** 594,601 ****
global $_CONF, $LANG28;
! $retval .= '<form action="' . $_CONF['site_admin_url'] . '/user.php" method="post" enctype="multipart/form-data">'
. $LANG28[29] . ': <input type="file" name="importfile" size="40">'
. '<input type="hidden" name="mode" value="import">'
. '<input type="submit" name="submit" value="' . $LANG28[30] . '"></form>';
return $retval;
}
--- 612,620 ----
global $_CONF, $LANG28;
! $retval = '<form action="' . $_CONF['site_admin_url'] . '/user.php" method="post" enctype="multipart/form-data">'
. $LANG28[29] . ': <input type="file" name="importfile" size="40">'
. '<input type="hidden" name="mode" value="import">'
. '<input type="submit" name="submit" value="' . $LANG28[30] . '"></form>';
+
return $retval;
}
***************
*** 652,661 ****
$display .= COM_siteFooter();
} else if ($mode == 'import') {
- $display .= COM_siteHeader('menu');
- $display .= COM_startBlock ($LANG28[31], '',
- COM_getBlockTemplate ('_admin_block', 'header'));
$display .= importusers ($HTTP_POST_VARS['file']);
- $display .= COM_endBlock (COM_getBlockTemplate ('_admin_block', 'footer'));
- $display .= COM_siteFooter();
} else if ($mode == 'importform') {
$display .= COM_siteHeader('menu');
--- 671,675 ----
More information about the geeklog-cvs
mailing list