2005-01-13 23:59:22 +00:00
< ?
2005-01-24 18:00:03 +00:00
/*
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 .
*/
?>
< ?
2007-12-20 16:41:57 +00:00
echo " To run this script, edit it and comment out the 'exit' (and this message) at the beginning " ;
2010-03-31 18:44:42 +00:00
//exit;
2005-01-13 23:59:22 +00:00
include " ../common.inc.php " ;
$numprojects = 150 ;
function getrand ( $ar )
{
return $ar [ rand ( 0 , count ( $ar ) - 1 )];
}
//the following work as one in x where x is the number below
$prob_dual = 3 ;
$prob_unpaid = 10 ;
$firstnames = array ( " James " , " Bob " , " Ali " , " Erin " , " Julia " , " Dave " , " Steve " , " Bryan " , " Jane " , " Elizabeth " , " Norm " , " Sue " , " Eric " , " Terry " , " Arthur " , " Angel " , " Allison " , " Jeremy " , " Jacqueline " , " Derek " , " Kristen " , " Greg " , " Cheryl " , " Debbie " , " Heather " , " Donald " , " Linda " , " George " , " Patrica " , " Carmel " , " Dawn " , " Scott " , " Brad " , " Bruce " , " Paul " , " Guillaume " );
$lastnames = array ( " Grant " , " Browning " , " Mehdi " , " Borque " , " Temple " , " Culhane " , " Sargent " , " Sing " , " Belanger " , " Desjardin " , " Jones " , " Smith " , " Brown " , " Johnson " , " Williams " , " White " , " Thompson " , " Baker " );
2007-11-27 22:47:06 +00:00
$domains = array ( " lightbox.org " , " microsoft.com " , " yahoo.com " , " msn.com " , " gmail.com " , " reach.net " , " slicer.ca " , " cwsf.ca " , " sfiab.ca " );
2005-01-13 23:59:22 +00:00
$nouns = array ( " age " , " animal " , " arm " , " baby " , " ball " , " bat " , " bear " , " boat " , " camp " , " car " , " child " , " circle " , " city " , " cotton " , " design " , " dog " , " dress " , " duck " , " ear " , " egg " , " enemy " );
$starters = array ( " effects of " , " study of " , " analysis of " );
$joiners = array ( " on " , " combined with " , " broken apart by " , " burned with " , " attacked by " , " left alone with " );
2010-03-31 18:44:42 +00:00
$numschools = mysql_query ( " SELECT id FROM schools WHERE year='2011' " );
2006-10-15 20:14:54 +00:00
while ( $s = mysql_fetch_object ( $numschools ))
{
//1 in 4 chance of actually using this school
$o = rand ( 1 , 4 );
if ( $o == 1 )
$schools [] = $s -> id ;
}
$ns = count ( $schools );
2005-01-13 23:59:22 +00:00
for ( $x = 0 ; $x < $numprojects ; $x ++ )
{
$id = 0 ;
$regnum = rand ( 100000 , 999999 );
$email = strtolower ( getrand ( $firstnames ) . " @ " . getrand ( $domains ));
$pd = rand ( 1 , $prob_unpaid );
if ( $pd == 1 ) $status = 'paymentpending' ; else $status = 'complete' ;
2010-03-31 18:44:42 +00:00
$q = mysql_query ( " INSERT INTO registrations (num,email,start,status,year) VALUES (' $regnum ',' $email ',NOW(),' $status ',2011) " );
2005-01-13 23:59:22 +00:00
if ( $id = mysql_insert_id ())
{
$peeps = rand ( 1 , $prob_dual );
if ( $peeps == 1 ) $num = 2 ; else $num = 1 ;
$gradenum = rand ( 1 , 10 );
2006-10-19 23:30:13 +00:00
if ( $gradenum < 7 ) { $grade = rand ( 7 , 8 ); $cat = 1 ;}
else if ( $gradenum < 9 ) { $grade = rand ( 9 , 10 ); $cat = 2 ; }
2005-01-13 23:59:22 +00:00
else if ( $gradenum < 10 ) { $grade = rand ( 11 , 12 ); $cat = 3 ; }
2006-10-15 20:14:54 +00:00
$schools_id = $schools [ rand ( 0 , $ns )];
2005-01-13 23:59:22 +00:00
for ( $a = 1 ; $a <= $num ; $a ++ )
{
$sexnum = rand ( 1 , 3 );
if ( $sexnum < 3 ) $sex = " male " ; else $sex = " female " ;
2006-10-19 23:30:13 +00:00
$firstname = getrand ( $firstnames );
$email = strtolower ( $firstname ) . " @ " . getrand ( $domains );
2010-03-31 18:44:42 +00:00
mysql_query ( " INSERT INTO students (registrations_id,firstname,lastname,email,sex,grade,year,schools_id) VALUES (' $id ',' $firstname ',' " . getrand ( $lastnames ) . " ',' $email ',' $sex ',' $grade ','2011',' $schools_id ') " );
2005-01-13 23:59:22 +00:00
}
$div = rand ( 1 , 6 );
$title = ucwords ( getrand ( $starters ) . " " . getrand ( $nouns ) . " " . getrand ( $joiners ) . " " . getrand ( $nouns ));
$req_enum = rand ( 1 , 4 );
if ( $req_enum == 1 ) $req_e = " yes " ; else $req_e = " no " ;
$req_tnum = rand ( 1 , 30 );
if ( $req_tnum == 1 ) $req_t = " no " ; else $req_t = " yes " ;
2006-01-26 23:10:39 +00:00
$langnum = rand ( 1 , 10 );
if ( $langnum < 4 ) $lang = " fr " ; else $lang = " en " ;
2005-01-13 23:59:22 +00:00
2006-01-26 23:10:39 +00:00
2010-03-31 18:44:42 +00:00
mysql_query ( " INSERT INTO projects (registrations_id,projectcategories_id,projectdivisions_id,title,year,req_electricity,req_table,language) VALUES (' $id ',' $cat ',' $div ',' $title $lang ',2011,' $req_e ',' $req_t ',' $lang ') " );
2005-01-13 23:59:22 +00:00
}
}
?>