Показать сообщение отдельно
Непрочитано 08.12.2008, 23:41   #21
Аватар для zasov
Пользователь

По умолчанию Ответ: L2Top, поощрение за голосование

не работает скрипт, а что насчет скрипта использующего телнет?

PHP код:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<meta http-equiv="content-type" content="text/html;charset=windows-1251"/>
<title>Reward over vote</title>
<link type="text/css" rel="stylesheet" href="./mycss.css">
<center>
<body alink="#00ff00" bgcolor="#FFFFFF" background="./dot.gif" link="#00c000" text="#008000" vlink="#00c000">
<img src='http://l2top.ru/catalog/top.php?id=' width='88' height='31' border='0'><br>
<script type="text/javascript">//<![CDATA[
function isAlphaNumeric(value)
{
    if (value.match(/^[a-zA-Z0-9]+$/))
        return true;
    else
        return false;
}
function checkform(f)
{
    if ((f.account.value=="") || (f.password.value=="") || (f.char_name.value==""))
    {
        alert("Заполните все поля!");
        return false;
    }
    if (!isAlphaNumeric(f.password.value) || !isAlphaNumeric(f.account.value) || !isAlphaNumeric(f.char_name.value))
    {
        alert("Допутим ввод цифр и букв!");
        return false;
    }
    return true;
}
//]]></script>
<font class="style16">Размер вознаграждения 200к аден.</font><br><br>
<form method="post" action="?act=vote" onsubmit="return checkform(this)">
<table>
 <tr>
  <td><b><font face="Trebuchet MS" size="2">Логин</font></b></td>
  <td><font face="Trebuchet MS" size="1"><b>
  <input type="text" name="account" maxlength="15" size="20" /></b></font></td>
 </tr>
 <tr>
  <td><b><font face="Trebuchet MS" size="2">Пароль</font></b></td>
  <td><font face="Trebuchet MS" size="1"><b>
  <input type="password" name="password" maxlength="15" size="20" value=""/></b></font></td>
 </tr>
 <tr>
 <tr>
  <td><b><font face="Trebuchet MS" size="2">Имя чара</font></b></td>
  <td><font face="Trebuchet MS" size="1"><b>
  <input type="text" name="char_name" maxlength="15" size="20" /></b></font></td>
 </tr>
 <tr>
  <td colspan="2" style="text-align: center;">
  <font size="1" face="Trebuchet MS"><b><br />
  <input type="submit" name="submit" value="Проголосовать" /></b></font></td>
 </tr>
</table>
</form>

<?php

error_reporting
(0);

$mysql_host "";
$mysql_port 3306;
$mysql_db "l2rt";
$mysql_login "";
$mysql_password "";

$telnet_host "127.0.0.1";
$telnet_port "7771";
$telnet_password "";
$telnet_timeout 10;

$ipaddr $_SERVER["REMOTE_ADDR"];
$la2topID "";
$item_id=57;
$item_count=200000;

if (
$_POST['submit'] && $_GET['act'])
{
    
$account $_POST['account'];
    
$password $_POST['password'];
    
$char_name $_POST['char_name'];

    if (
ereg("^([a-zA-Z0-9_-])*$"$account ) && ereg("^([a-zA-Z0-9_-])*$"$password) && ereg("^([a-zA-Z0-9_-])*$"$char_name))
    {
        
$link mysql_connect($mysql_host$mysql_login$mysql_password);
        if (!
$link)
            die(
"Couldn't connect to MySQL");
        @
mysql_select_db($mysql_db$link)
            or die (
'Error '.mysql_errno().': '.mysql_error());

        if (
$char_name && $account && strlen($account)<16 && strlen($account)>&& $password)
        {
            
$sql "select login, lastip from `accounts` where `login`='$account' and `password`='".base64_encode(pack('H*'sha1($password)))."';";
            
$check mysql_query($sql);
            
$row mysql_num_rows($check);
            if (
$row)
            {
                
$sql "select * from characters where `account_name`='$account' and `char_name`='$char_name';";
                
$check mysql_query($sql);
                
$row mysql_num_rows($check);
                if (
$row)
                {
                    
$user_id mysql_result($check,0,"obj_id");
                    
$useronline mysql_result($check,0,"online");
                    if(
l2topcheck($la2topID$ipaddr)&&dbcheck($ipaddr$account))
                    {
                    echo 
'<iframe src="http://l2top.ru/?servID='.$la2topID.'&act=vote" frameborder="0" width="1" height="1">Hello</iframe>';
                        if (
$useronline)
                        {
                            
$usetelnet fsockopen($telnet_host$telnet_port$errno$errstr$telnet_timeout);
                            if(
$usetelnet)
                            {
                                
$give_string 'give '.$char_name.' ' .$item_id.' '.$item_count;
                                
fputs($usetelnet$telnet_password);
                                
fputs($usetelnet"\r\n");
                                
fputs($usetelnet$give_string);
                                
fputs($usetelnet"\r\n");
                                
fputs($usetelnet"exit\r\n");
                                
fclose($usetelnet);
                            }
                            else
                            {    echo 
"<font color=\"red\">Ошибка:</font>Невозможно подключится к телнету";    }
                        }
                        else
                        {
                            
$sql="select * from `items` where `owner_id`='$user_id' and `item_id`='$item_id' and `loc`='INVENTORY'";
                            
$result mysql_query($sql);
                            
$item_count mysql_result($result,0,"count")+$item_count;

                            
$sql "update `items` set `count`='$item_count' where `owner_id`='$user_id' and `item_id`='$item_id' and `loc`='INVENTORY'";
                            
mysql_query($sql);
                        }
                        echo 
"<br><font class=\"mystyle\"> Вы успешно прголосовали за сервер и получили нагрду<br></font>";
                    }
                    else
                    {
                        echo 
"<font class=\"mystyle\" color=\"red\">Вы не можете голосовать.</font>";
                    }
                }
                else
                {    echo 
"<font class=\"mystyle\" color=\"red\">Чара с таким именем не существует.</font>";    }
            }
            else
            {    echo 
"<font class=\"mystyle\" color=\"red\">Логин или пароль введён не верно.</font>";    }
        }
        else
        {    echo 
"<font cclass=\"mystyle\" color=\"red\">Логин или пароль введён не верно.</font>";    }
        
mysql_close($link);
    }
}
function 
l2topcheck($la2topID$ipaddr)
{
    
$fcontent=file_get_contents("http://l2top.ru/?servID=".$la2topID."&act=info");
    if(
strstr($fcontent,$ipaddr))
    {    return 
false;    }
    else
    {    return 
true;    }
}
function 
dbcheck($ipaddr$account)
{
    
$sql "select * from rewardovervote where `ipaddr`='$ipaddr' or `name`='$account'";
    
$check mysql_query($sql);
    
$row mysql_num_rows($check);
    if(
$row)
    {
        
$time mysql_result($check,0,"date");
        if( (
time()-$time) > (60*60*24) )
        {
            
$sql "update `rewardovervote` set `date`=".time()." where `ipaddr`='$ipaddr' and `name`='$account'";
            
mysql_query($sql);
            return 
true;
        }
        else
        {    return 
false;    }
    }
    else
    {
        
$sql "insert into `rewardovervote` (name, date, ipaddr) VALUE ('$account', ".time().", '$ipaddr')";
        
mysql_query($sql);
        return 
true;
    }
}
?>
в базу это втыкать
PHP код:
CREATE TABLE `rewardovervote` (
  `
namevarchar(30NOT NULL default '',
  `
dateint(11NOT NULL default '0',
  `
ipaddrvarchar(30NOT NULL default '',
  
PRIMARY KEY  (`name`), 
  
UNIQUE KEY `id` (`name`) );
); 
только вот на CCP в телнете Give не работает какая там команда на выдачу?
zasov вне форума Ответить с цитированием