<?php
// a simple mysql_connect statement to connect to the right database with the right user
include('../connect-stprex.php');

// list all your users
$users=array('davida',
'quentina','telmad',
'matthieud',
'heloisew',
'centrale');

// do a bunch of things for each user
foreach ($users as $user)
{
// in here, a list of changes we want to make to the database for each blog. Things I changed left as examples -- modify to your taste/needs.

// options table stuff
print("<br /><br /><strong>$user</strong><br /><br />\n");

$table$user "_options";

$prenom=ucfirst(substr($user0, -1));
$initiale=ucfirst(substr($user, -1)) . ".";
$pairs['fileupload_realpath']='home/edublogs/st-prex/'.$user.'/images/';
$pairs['time_format']='G:i';
$pairs['fileupload_url']='http://st-prex.edublogs.net/' $user '/';
$pairs['date_format']='Y-m-d';
$pairs['siteurl']='http://st-prex.edublogs.net/' $user;
$pairs['new_users_can_blog']='0';
$pairs['users_can_register']='0';
$pairs['admin_email']='edublogs@gmail.com';
$pairs['permalink_structure']='/archives/%year%/%monthnum%/%day%/%postname%/';
$pairs['category_base']='/categories';
$pairs['blogname']="Le weblog de $prenom $initiale";
$pairs['blogdescription']="Projet interdiciplinaire 8VSG, St.-Prex.";

foreach(
$pairs as $option => $value)
 {
  
mysql_query("update $table set option_value = '$value' where option_name = '$option'") or die("Oops. Couldn't set field $option to value $value for user $user. Sorry!");  
print(
"Set $value as $option for $user.<br />\n");
  }

// change default link category name

$table$user "_linkcategories";

mysql_query("UPDATE `$table` SET `cat_name` = 'Liens' WHERE `cat_id` = '1'") or die('Problem changing link category name.') ;

// change admin password

$table $user "_users"

// note: here, the admin password is already md5-encrypted
mysql_query("UPDATE `$table` SET `user_pass` = '66da2d5e' WHERE `user_login` = 'admin'") or die('Problem setting admin password.') ;
print(
"updated admin password<br />\n");

// add level 3 user
// do fancy stuff to make the password look random enough
$password[$user]= substr($user, -1) . '4gn2' substr($user, -4) . 'de9' $initiale '3d22';
$table=$user "_users";
mysql_query("INSERT INTO `$table
( `ID` , `user_login` , `user_pass` , `user_firstname` , `user_lastname` , `user_nickname` , `user_icq` , `user_email` , `user_url` , `user_ip` ,
 `user_domain` , `user_browser` , `dateYMDhour` , `user_level` , `user_aim` , `user_msn` , `user_yim` , `user_idmode` , `user_description` ,
 `user_activation_key` , `user_status` , `user_nicename` ) VALUES ('', '
$user',  MD5( '$password[$user]' ) , '$prenom', '$initiale',
 '
$prenom $initiale', '0', '', '', '127.0.0.1', '127.0.0.1', '', '0000-00-00 00:00:00', '3', '', '', '', 'nickname', '', '', '0', '$user')"
or die(
"Problem creating $user.");
print(
"created $user<br /><br />\n");
}

// print a list of all user/pass (could also print a list of all the urls to the weblogs, etc)
foreach($password as $user => $pass)
{
print(
"$user$pass<br />\n");
}
?>