Вход Регистрация
Файл: region_clean/bot_bartender.php
Строк: 95
<?php

class bot_bartender{
    public 
$msg;
    public 
$team;
    public 
$update_money;
    public 
$update_alcohol;
    public 
$config;
    public 
$drinks = array();
    public 
$food = array();
    public 
$youDrunk = array();
    public 
$userProfile = array();
    public 
$eda;

    
/*
    * $login   - Логин юзера
    * $alcohol - уровень опьянения юзера
    * $money   - Количество денег на счету у юзера
    * $keyLog  - Ключ (ид юзера) для лога его покупок
    **/
    
function __construct($alcohol$money$keyLog) {
        
$this->alcohol $alcohol;
        
$this->money $money;
        
//Лог файл
        
$this->logFole 'data/bot_bartender/log/'.$keyLog.'.dat';        //Настройки бота
        
$this->config parse_ini_file('data/bot_bartender/config.ini');
        
//Авто Очистка лога
        
if (!$alcohol && file_exists($this->logFole)) unlink($this->logFole);

    }

    
/*Анализ сообщение
    * $msg - Сообшение
    * Функция возвращает
    * 1 - если чел слишком пьян
    * 2 - если у чела нет денег для оплаты
    * 3 - Заказ выполнен
    */
    
public function analysis($msg) {
    
$this->msg $msg;
        
preg_match("#!(.*?)(s|$)#i"$msg$arr);
        if (
$this->alcohol $this->config['font']) {
                
$this->msg $this->font($msg);
        }
        
/*Стриптиз*/
        
$mony_strip 100//Цена стриптиза
        
$strip = array('стрип''стриптиз''strip''striptiz');

        if (
in_array(mb_strtolower($arr[1], 'UTF-8'), $strip)) {             if ($mony_strip $this->money) return 2;
            
$this->eda true//Чтоб тост не говорило
            
$this->team 'стриптиз';
            
$this->setLog();
            
$this->team .= ' <img src="utils/resize.php?img='.$this->randImg().'&width=150&height=0" alt="" />';
            
$this->update_money $this->money-$mony_strip;
            
$this->update_alcohol 0;
            return 
3;         }

        
$sql mysql_query("SELECT * FROM bot_bartender_product WHERE name = '".mysql_real_escape_string(mb_strtolower($arr[1], 'UTF-8'))."'");
        
$res mysql_fetch_assoc($sql);
        if (!empty(
$res['name'])) {             $this->eda $res['alcohol'] < true false;
            
$this->update_alcohol $this->alcohol $this->alcohol+$res['alcohol'] : $res['alcohol'];
            if (!
$this->eda && ($this->update_alcohol $this->config['youdrunk'])) {
                return 
1;
            } elseif (
$res['price'] > $this->money) {
                return 
2;
            } else {
                
$this->update_money $this->money-$res['price'];
                if (
$this->update_alcohol >= 100) {
                    
$this->update_alcohol 100;
                } elseif (
$this->update_alcohol 0) {
                    
$this->update_alcohol 0;
                }
                
$this->update_alcohol abs($this->update_alcohol);
                
$this->team $res['name'];
                
$this->setLog();
                if (
is_file('upload/bot_bartender/'.$res['id'].'.img')) {
                    
$this->team .= ' <img src="utils/resize.php?img=upload/bot_bartender/'.$res['id'].'.img&width=100&height=0" alt="" />';
                }

                return 
3;
            }
        }
    }

    
//Случайный тост
    
public function toast() {
        
$data file('data/bot_bartender/toast.dat');
        return 
$data[array_rand($data)];
    }
    
//Случайное оповешение о том что юзер пьян
    
public function youDrunk() {
        
$data file('data/bot_bartender/you_drunk.dat');
        return 
$data[array_rand($data)];
    }
    
//Преобразование текста в ПрЫгАюЩиЙ регистр
    
public function font($msg) {
        
$msg iconv("UTF-8""windows-1251"$msg);
        
$count strlen($msg);
        for(
$i 0$i<$count$i++) {
            
$r $r 1;
            
$txt .= $r mb_strtoupper($msg[$i], 'windows-1251') : mb_strtolower($msg[$i], 'windows-1251');
        }
        return 
iconv("windows-1251",  "UTF-8"$txt);
    }

    
//Запись в лог покупок
    
public function setLog() {
        
$fp fopen($this->logFole'a+');
        
flock ($fpLOCK_EX);
        
fwrite($fp$this->team.'('.date("d.m.Y H:i").')<br/>');
        
flock ($fpLOCK_UN);
        
fclose($fp);
        @
chmod($this->logFole0666);
    }
    
//Загрузка лога
    
public function getLog() {
        return 
file_exists($this->logFole) ? file_get_contents($this->logFole) : 'История пока пуста...';
    }

    
//Случайная картинка
    
public function randImg() {         $data unSerialize(file_get_contents('data/bot_bartender/strip.dat'));
        return 
$data[array_rand($data)];
    }
}
?>
Онлайн: 1
Реклама