Exemplo n.º 1
0
        for ($k = 0; $k < $classMateNum; $k++) {
            $year = mt_rand(1992, 2000);
            $vez = mt_rand(0, 15);
            $ker = mt_rand(0, 27);
            $yearClass = $i;
            $groupClass = $classes[$j];
            $loginCode = generateRandomString(8) . ".kf";
            $name = $vezeteknev[$vez] . " " . $keresztnev[$ker];
            $birth = getBirthDate($year);
            $city = $varos[mt_rand(0, 3)];
            $s_hostel = mt_rand(0, 1);
            $allowance = mt_rand(0, 1);
            $password = sha1("asd12345");
            $email = $vezeteknev_email[$vez] . "." . $keresztnev_email[$ker] . $year . "@kf-szeged.hu";
            $ppn = "+3630" . mt_rand(1111111, 9999999);
            addNewStudent($loginCode, $name, $birth, $city, $password, $email, $ppn, $yearClass, $groupClass, $s_hostel, $allowance);
            $z++;
        }
    }
}
echo $z;
function addNewStudent($login_code, $name, $birth, $resi, $pass, $email, $ppn, $year, $class, $s_hostel, $allowance)
{
    $sql = "INSERT INTO students VALUES ('', ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
    $string = array($login_code, $name, $birth, $resi, $s_hostel, $allowance, $pass, $email, $ppn, $year, strtolower($class));
    $db = new DatabaseConnection("localhost", "adminuser", "asd12345", "school");
    $db->queryWithoutResult($sql, $string, true, "ssssiisssis");
    $sql = 'SELECT id FROM students WHERE login_code = ?';
    $string = array($login_code);
    $res = $db->select($sql, $string, true, 's');
    $zero = mt_rand(0, 18);
Exemplo n.º 2
0
$vezeteknev_email = array("toth", "nagy", "vincze", "kurucz", "fabian", "kovacs", "pap", "gorog", "molnar", "varga", "turo", "nemeth", "csikos", "szucs", "voros", "deak");
$keresztnev = array("Lilla", "Ferenc", "István", "Gábor", "Anna", "Beáta", "Ödön", "Márk", "Flóra", "Áron", "Árpád", "Csilla", "Erzsébet", "Rita", "Balázs", "Kármen", "Judit", "Álmos", "Dániel", "Kornélia", "Ernesztina", "Renáta", "Kornél", "Zsolt", "Imre", "Béla", "Tamás", "Konrád");
$keresztnev_email = array("lilla", "ferenc", "istvan", "gabor", "anna", "beata", "odon", "mark", "flora", "aron", "arpad", "csilla", "erzsebet", "rita", "balazs", "karmen", "judit", "almos", "daniel", "kornelia", "ernesztina", "renata", "kornel", "zsolt", "imre", "bela", "tamas", "konrad");
$varos = array("Szeged", "Algyő", "Sándorfalva", "Domaszék");
for ($i = 0; $i < count($subjects); $i++) {
    $code = generateRandomString(4) . ".kf";
    $vez = mt_rand(0, 15);
    $ker = mt_rand(0, 27);
    $name = $vezeteknev[$vez] . " " . $keresztnev[$ker];
    $year = mt_rand(1970, 1990);
    $birth = getBirthDate($year);
    $pass = sha1("asd12345");
    $email = $vezeteknev_email[$vez] . "." . $keresztnev_email[$ker] . $year . "@kf-szeged.hu";
    $pn = "+3630" . mt_rand(1111111, 9999999);
    $city = $varos[mt_rand(0, 3)];
    addNewStudent($code, $name, $birth, $pass, $email, $pn, $city, $subjects[$i]);
}
function addNewStudent($login_code, $name, $birth, $pass, $email, $pn, $city, $subj)
{
    $sql = "INSERT INTO teachers VALUES ('', ?, ?, ?, ?, ?, ?, ?)";
    $string = array($login_code, $name, $birth, $pass, $email, $pn, $city);
    $db = new DatabaseConnection("localhost", "adminuser", "asd12345", "school");
    $db->queryWithoutResult($sql, $string, true, "sssssss");
    $sql = 'SELECT id FROM teachers WHERE code = ?';
    $string = array($login_code);
    $res = $db->select($sql, $string, true, 's');
    $sql = "INSERT INTO teacher_subj VALUES (?,?)";
    $string = array($res[0]['id'], $subj);
    $db->queryWithoutResult($sql, $string, true, "is");
    return true;
}