Add a script to empty out the registrations, students and projects

Update populate_fake script to be more realistic and to add email addresses
This commit is contained in:
james 2006-10-19 23:30:13 +00:00
parent 06cb40304b
commit 2c6568ca22
2 changed files with 43 additions and 3 deletions

View File

@ -0,0 +1,38 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
Copyright (C) 2005 James Grant <james@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
?>
<?
include "../common.inc.php";
echo "WARNING: THIS REMOVES ALL INFO FROM THE STUDENTS & PROJECTS & REGISTRATIONS TABLES, NOT JUST THE AUTO-GENERATED ONES. THIS SCRIPT SHOULD NEVER BE USED IN A REAL-LIFE SITUATION";
echo "\n";
echo "IF YOU ARE SURE YOU WANT TO RUN THIS, SET AN ARGUMENT TO THE SCRIPT, EG 'php emptyregistrations.php true'\n";
if(count($argv)>1)
{
echo "TRUNCATING TABLE DATA....\n";
mysql_query("TRUNCATE TABLE registrations");
mysql_query("TRUNCATE TABLE students");
mysql_query("TRUNCATE TABLE projects");
echo "DONE.\n\n";
}
?>

View File

@ -73,8 +73,8 @@ for($x=0;$x<$numprojects;$x++)
if($peeps==1) $num=2; else $num=1;
$gradenum=rand(1,10);
if($gradenum<6) { $grade=rand(7,8); $cat=1;}
else if($gradenum<8) { $grade=rand(9,10); $cat=2; }
if($gradenum<7) { $grade=rand(7,8); $cat=1;}
else if($gradenum<9) { $grade=rand(9,10); $cat=2; }
else if($gradenum<10) { $grade=rand(11,12); $cat=3; }
$schools_id=$schools[rand(0,$ns)];
@ -84,7 +84,9 @@ for($x=0;$x<$numprojects;$x++)
$sexnum=rand(1,3);
if($sexnum<3) $sex="male"; else $sex="female";
mysql_query("INSERT INTO students (registrations_id,firstname,lastname,sex,grade,year,schools_id) VALUES ('$id','".getrand($firstnames)."','".getrand($lastnames)."','$sex','$grade','2007','$schools_id')");
$firstname=getrand($firstnames);
$email=strtolower($firstname)."@".getrand($domains);
mysql_query("INSERT INTO students (registrations_id,firstname,lastname,email,sex,grade,year,schools_id) VALUES ('$id','$firstname','".getrand($lastnames)."','$email','$sex','$grade','2007','$schools_id')");
}