Файл: masteram_us/user/invite.php
Строк: 36
<?php
require'../shaxty.php'; // waphp.ru - закрытый клуб вап мастеров!
check_login();
$title = 'Приглашения';
$align = 'left';
$head = 'Приглашения';
include_once (H.'shaxty/head.php');
    function GenCode($size)
    {
        $letter = 'qwertyuipasdfghjklzxcvbnm';
        $letter .= strtoupper($letter);
        $letter .= '123456789';
        mt_srand((double)microtime() * 1000000);
        $genCode = '';
        for ($i = 0; $i < $size; ++$i)
        $genCode .= $letter[mt_rand(0, strlen($letter) - 1)];
        return $genCode;
    }
    $file = file_get_contents('invites.dat');
    $eX = explode('|', $file);
              if ($eX[1] != 1) {
                    header('Location: /?');
                    die();
              }
    if ($eX[0] > $user['level']) {
        echo '<b style="color:red;">Приглашения будут доступны с уровня ' . level($eX[0]) . '!</b><br/>';
        include_once (H.'shaxty/foot.php');
        exit();
    }
    $resultInv = mysql_query("SELECT scode FROM invite WHERE user = '$user[id]' AND inv_user = '0'");
        if ($eX[0] <= $user['level'] && mysql_num_rows($resultInv) == false) {
            for($j = 0; $j < 3; $j++)
            {
                mysql_query("INSERT INTO invite SET user = '$user[id]', scode = '" . GenCode(8) . "'");
            }
            header('Location: ?');
        }
        echo 'Ваши коды для приглашений:<hr/>';
    if (mysql_num_rows($resultInv)) {
        while($sQL = mysql_fetch_assoc($resultInv))
        {
            echo '<input type="text" value="' . $sQL['scode'] . '"/><br/>---<br/>';
        }
    } else {
        echo 'Коды приглашений закончились.<br/>';
    }
include_once (H.'shaxty/foot.php');
?>