science-ation/scripts/populate_fake.php

73 lines
2.6 KiB
PHP
Raw Normal View History

<?
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");
$domains=array("lightbox.org","microsoft.com","yahoo.com","msn.com","gmail.com","reach.net","slicer.ca","cwsf.ca"."sfiab.ca");
$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");
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';
$q=mysql_query("INSERT INTO registrations (num,email,start,status,year) VALUES ('$regnum','$email',NOW(),'$status',2005)");
if($id=mysql_insert_id())
{
$peeps=rand(1,$prob_dual);
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; }
else if($gradenum<10) { $grade=rand(11,12); $cat=3; }
$schools_id=rand(1,2);
for($a=1;$a<=$num;$a++)
{
$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',2005,'$schools_id')");
}
$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";
mysql_query("INSERT INTO projects (registrations_id,projectcategories_id,projectdivisions_id,title,year,req_electricity,req_table) VALUES ('$id','$cat','$div','$title',2005,'$req_e','$req_t')");
}
}
?>