php WapCraft regPage author Alex Priadko Elfi package WapCraft defined

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/**
* WapCraft regPage
* @author Alex Priadko (Elfi)
* @package WapCraft
*/
defined('R') or die (header("Location:/"));
$cm->access=0;
$cm->params='Reg';
$cm->conf();
$query_counter = $db->query("SELECT `id` FROM `users` WHERE `id`>0");
$counter = $query_counter->rowCount();
$nick = 'Игрок '.$counter+=$counter;
$passgen = rand (111,999);
$stmt = $db->prepare ("INSERT INTO `users` SET `login`=?,`password`=?");
$stmt->execute(array($nick,$passgen));
$newUser = $db->prepare("SELECT * FROM `users` WHERE `login` =? and
`password`=? ");
$newUser->execute(array($nick,$passgen));
$newUser = $newUser->fetch();
if (isset($newUser))
{
$_SESSION['tocken'] = $controller->genTockenAuth($newUser['id']);
$stmh = $db->prepare("UPDATE `users` SET `session_key`=?, `session_life`=?
WHERE `id`=?");
$stmh->execute(array($_SESSION['tocken'],
$controller->getSessionLife($newUser['id']),
$newUser['id']));
header("Location:/");
exit;
}