Example #1
0
function ToDoSomething($keyword, $text)
{
    global $input;
    $output = null;
    switch ($keyword) {
        case 'Greeterings':
            $a = array("Привет", "Здравствуй", "Приветище", "Здарова");
            if (rand(1, 2) == 1) {
                $curhour = date("G");
                switch ($curhour) {
                    case $curhour < 6:
                    case $curhour >= 23:
                        $output = "Доброй ночи";
                        break;
                    case $curhour >= 6 && $curhour < 12:
                        $output = "Доброе утро";
                        break;
                    case $curhour >= 12 && $curhour < 18:
                        $output = "Добрый день";
                        break;
                    case $curhour >= 18 && $curhour < 23:
                        $output = "Добрый вечер";
                        break;
                }
            } else {
                $output = $a[array_rand($a)];
            }
            break;
        case 'WorkWithJournal':
            $mysqli = new mysqli('localhost', MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE);
            if ($mysqli->connect_errno) {
                $output = "Не удалось подключиться к MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
            }
            if (FindText($text, array('очисти', 'удали', 'снеси'))) {
                $query = "truncate journal";
                if ($result = $mysqli->query($query)) {
                    $output = "Журнал очищен, {m-name}.\r\n";
                }
            } else {
                $output = "Последние записи из журнала:\r\n";
                if (!$mysqli->query("SET NAMES 'utf8'")) {
                    $output = "Не удалось подключиться: (" . $mysqli->errno . ") " . $mysqli->error;
                }
                $mysqli->query("SET SESSION collation_connection = 'utf8_general_ci'");
                $query = "select * from journal ORDER BY id DESC LIMIT 10";
                if ($result = $mysqli->query($query)) {
                    while ($row = mysqli_fetch_assoc($result)) {
                        $output .= "{$row['username']} ({$row['chat_id']}) в {$row['m_datetime']}: {$row['message']} \r\n";
                    }
                }
            }
            $mysqli->close();
            break;
        case 'Passwords':
            if (FindText($text, array('генер', 'дела', 'придум'))) {
                $chars = "qazxswedcvfrtgbnhyujmkiolp1234567890QAZXSWEDCVFRTGBNHYUJMKIOLP";
                if (mb_stripos($text, "сложн", 0, "utf-8") !== false) {
                    $chars .= "~!@#\$%^&*_+/.,<>[]{};:-=";
                }
                $max = 8;
                $size = StrLen($chars) - 1;
                $output = null;
                while ($max--) {
                    $output .= $chars[rand(0, $size)];
                }
                file_put_contents("tmp_pass", $output);
            } elseif (FindText($text, array('запомни', 'сохрани'))) {
                file_put_contents("promise." . $input['user_id'], "Password4DB");
                $a = array("Как обозвать?", "Как назвать?", "Какой ярлык присвоить?", "Какое имя ему дать?", "Как назовём?", "Какой псевдоним ему присвоить?");
                $output = $a[array_rand($a)];
            } elseif (FindText($text, array('покажи', 'выведи', 'закешь', 'показ'))) {
                $mysqli = new mysqli('localhost', MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE);
                $mysqli->query("SET NAMES 'utf8'");
                $mysqli->query("SET SESSION collation_connection = 'utf8_general_ci'");
                if (FindText($text, 'парол')) {
                    $output = "Список паролей:\r\n";
                    $query = "select * from passwords";
                } elseif (preg_match('/пароль ([a-zA-Z а-яА-Я0-9ёЁ]+)/ui', $text, $matches)) {
                    $query = "select * from passwords where pname='" . $matches[1] . "'";
                }
                $flag = false;
                if ($result = $mysqli->query($query)) {
                    while ($row = mysqli_fetch_assoc($result)) {
                        $output .= "{$row['pname']} ({$row['p_datetime']}): {$row['pass']} \r\n";
                        $flag = true;
                    }
                }
                if (!$flag) {
                    $output = "Список пуст.\r\n";
                }
                $mysqli->close();
            } elseif (FindText($text, array('очисти', 'удали', 'снеси'))) {
                if (FindText($text, 'пароли')) {
                    $query = "truncate passwords";
                    $tmp = "Пароли удалены";
                } elseif (preg_match('/пароль ([a-zA-Z а-яА-Я0-9ёЁ]+)/ui', $text, $matches)) {
                    $query = "delete from passwords where pname='" . $matches[1] . "'";
                    $tmp = "Пароль удалён";
                    echo $query;
                }
                Query2DB($query);
                $a = array("Готово", "Задание выполнено", "Сделано", $tmp . ", {m-name}", "Сделала", "Выполнено");
                $output = $a[array_rand($a)];
            }
            break;
        case 'IntuitLink':
            if (FindText($text, array('пхп', 'php', 'пехепе'))) {
                $output = "http://www.intuit.ru/studies/courses/42/42/info или http://www.specialist.ru/dictionary/definition/php";
            }
            break;
        case 'Amen':
            if (FindText($text, array('пхп', 'php', 'пехепе'))) {
                $a = array("Аминь!", "Воистину гавно!", "Базаришь");
                $output = $a[array_rand($a)];
            }
            break;
        case 'MarkKing':
            if (preg_match('/(@[A-Za-z0-9_]{5,}) #узбек/ui', $text, $matches)) {
                $query = "insert into kings(username) values ('" . $matches[1] . "')";
                $output = "Отметила";
            }
            break;
    }
    return $output;
}
Example #2
0
$text = 'location = url';
$pos = FindText($file, $text, 1);
if ($pos == 'yes') {
    echo 'SUCCESS File: ' . $file . ' Text: <b>' . $text . '</b> already installed <br />';
} else {
    if ($pos == 'no') {
        echo 'FAIL&nbsp;&nbsp;&nbsp;&nbsp;Text: <b>' . $text . '</b> not found in file: ' . $file . ' <br />';
        $error++;
    } else {
        $text = "\n\t\tvar filter_model = \$('input[name=\\'filter_model\\']').attr('value');\t\n\tif (filter_model) {\n\t\turl += '&filter_model=' + encodeURIComponent(filter_model);\n\t} /*suppler*/\n ";
        Insert($file, $pos, $text, $error);
    }
}
$file = "admin/view/template/common/header.tpl";
$text = '<li><a href="<?php echo $download; ?>">';
$pos = FindText($file, $text, 1);
if ($pos == 'yes') {
    echo 'SUCCESS File: ' . $file . ' Text already installed <br />';
} else {
    if ($pos == 'no') {
        echo 'FAIL&nbsp;&nbsp;&nbsp;&nbsp;Text not found in file: ' . $file . ' <br />';
    } else {
        $text = ' 
		  <li><a href="<?php echo $suppler; ?>"><?php echo $text_suppler; ?></a></li> <!--*suppler*-->
 ';
        Insert($file, $pos, $text, $error);
    }
}
require_once 'config.php';
$dbhost = DB_HOSTNAME;
$dbuser = DB_USERNAME;