HOME FORUMS MEMBERS RECENT POSTS LOG IN  
× Авторизация
Имя пользователя:
Пароль:
Нет аккаунта? Регистрация
НОВЫЕ ТОРГОВАЯ НОВОСТИ ЧАТ
loading...
Скрыть
Вернуться   ANTICHAT > ПРОГРАММИРОВАНИЕ > PHP
   
Ответ
 
Опции темы Поиск в этой теме Опции просмотра

Парсинг формы для гет/пост запроса
  #1  
Старый 17.04.2009, 05:57
rcc0023
Участник форума
Регистрация: 03.07.2008
Сообщений: 177
С нами: 9398085

Репутация: 11
По умолчанию Парсинг формы для гет/пост запроса

Есть ли готовые варианты (с script изменением) для подготовки запроса? То есть есть форма:

Цитата:
<form name=log action='login.php' method=post><input type=hidden name=LOGIN_redirect value=1>

<input name="login" type="text" maxlength=150 class="id" title='Логин в игре'
value=' Имя персонажа' onfocus="clearLogin();">
<input name="pass" class="id2" type="password" maxlength=20 title='Пароль в игре' value='12345678901234567890' onfocus="clearPassw();">
<input type=hidden name="preseted" value=0>
<input type=image name=lbut src='i/index/left_buttons21.jpg' title='Войти в игру!'></form>

<script type="text/javascript"> function clearLogin() { if (log.lreseted.value == 0) { log.login.value= ''; log.lreseted.value = 1; } } function clearPassw() { if (log.preseted.value == 0) { log.pass.value= ''; log.preseted.value = 1; } } </script>

запрос брал так...
PHP код:
 $lbutx=rand(1,57); $lbuty=rand(1,17);  $game_login_u=rawurlencode($game_login); $game_pass_u=rawurlencode($game_pass);  $html=file_get_contents($url.'index.php');  $html=str_replace('"','',$html); $html=str_replace("'",'',$html); $html=str_replace('>',' >',$html); $html_2=str_replace(' ','',$html);  $text_01='<input';  $text_1=explode($text_01,$html); $text_2=explode('<form',$html); $text_3=explode('>',$text_2); $text_12=explode('name=',$text_3); $text_13=explode(' ',$text_12); $text_14=explode('action=',$text_3); $text_15=explode(' ',$text_14);  $f_forma_name=$text_13$f_forma_action=$text_15;  $no_error_1=substr_count($html,$text_01);  while($no_error_1 >= $key){  $html_str2=explode('>',$text_1);  $html_str=$html_str2;  $text_4=explode('name=',$html_str); $text_5=explode(' ',$text_4); $text_6=explode('type=',$html_str); $text_7=explode(' ',$text_6); $text_8=explode('value=',$html_str); $text_9=explode(' ',$text_8); $text_10=explode($f_forma_name.'.'.$text_5.'.value=',$html_2); $text_11=explode(';',$text_10);  $f_name=$text_5$f_type=$text_7$f_value=$text_9$f_java_value=$text_11;  $limit_1=substr_count($html,$f_forma_name.'.'.$f_name.'.value'); $limit_2=substr_count($html_str,'Логин'); $limit_3=substr_count($html_str,'Имя персонажа');  if($data_form_auth!='' and $znak!='&'){$znak='&';};      if($f_type=='password'){$data_form_auth.=$znak.''.$f_name.'='.$game_pass_u;} elseif(($limit_2 || $limit_3 0) and $f_type=='text'){$data_form_auth.=$znak.$f_name.'='.$game_login_u;} elseif($limit_1==2){$data_form_auth.=$znak.$f_name.'='.$f_java_value;} elseif($f_type=='image' and $f_name=="lbut"){$data_form_auth.=$znak.'lbut.x='.$lbutx.'&lbut.y='.$lbuty;} elseif($f_type=='hidden'){$data_form_auth.=$znak.$f_name.'='.$f_value;};  ++$key;                           }; 
в итоге получалось по типу такого: login=rcc0023&pass=hohoho&preseted=1

Как можно сделать оптимальней?

Последний раз редактировалось rcc0023; 17.04.2009 в 14:17..
 
Ответить с цитированием

  #2  
Старый 17.04.2009, 06:00
rcc0023
Участник форума
Регистрация: 03.07.2008
Сообщений: 177
С нами: 9398085

Репутация: 11
По умолчанию

более раскрыто...
Цитата:
$lbutx=rand(1,57);
$lbuty=rand(1,17);

$game_login_u=rawurlencode($game_login);
$game_pass_u=rawurlencode($game_pass);

$html=file_get_contents(index.php');

$html=str_replace('"','',$html);
$html=str_replace("'",'',$html);
$html=str_replace('>',' >',$html);
$html_2=str_replace(' ','',$html);

$text_01='<input';

$text_1=explode($text_01,$html);
$text_2=explode('<form',$html);
$text_3=explode('>',$text_2[1]);
$text_12=explode('name=',$text_3[0]);
$text_13=explode(' ',$text_12[1]);
$text_14=explode('action=',$text_3[0]);
$text_15=explode(' ',$text_14[1]);

$f_forma_name=$text_13[0];
$f_forma_action=$text_15[0];

$no_error_1=substr_count($html,$text_01);

while($no_error_1 >= $key){

$html_str2=explode('>',$text_1[$key]);

$html_str=$html_str2[0];

$text_4=explode('name=',$html_str);
$text_5=explode(' ',$text_4[1]);
$text_6=explode('type=',$html_str);
$text_7=explode(' ',$text_6[1]);
$text_8=explode('value=',$html_str);
$text_9=explode(' ',$text_8[1]);
$text_10=explode($f_forma_name.'.'.$text_5[0].'.value=',$html_2);
$text_11=explode(';',$text_10[2]);

$f_name=$text_5[0];
$f_type=$text_7[0];
$f_value=$text_9[0];
$f_java_value=$text_11[0];

$limit_1=substr_count($html,$f_forma_name.'.'.$f_n ame.'.value');
$limit_2=substr_count($html_str,'Логин');
$limit_3=substr_count($html_str,'Имя персонажа');

if($data_form_auth!='' and $znak!='&'){$znak='&';};

if($f_type=='password'){$data_form_auth.=$znak.''. $f_name.'='.$game_pass_u;}
elseif(($limit_2 > 0 || $limit_3 > 0) and $f_type=='text'){$data_form_auth.=$znak.$f_name.'= '.$game_login_u;}
elseif($limit_1==2){$data_form_auth.=$znak.$f_name .'='.$f_java_value;}
elseif($f_type=='image' and $f_name=="lbut"){$data_form_auth.=$znak.'lbut.x='. $lbutx.'&lbut.y='.$lbuty;}
elseif($f_type=='hidden'){$data_form_auth.=$znak.$ f_name.'='.$f_value;};

++$key;

};

Последний раз редактировалось rcc0023; 17.04.2009 в 14:13..
 
Ответить с цитированием

  #3  
Старый 17.04.2009, 09:56
Gifts
Reservists Of Antichat - Level 6
Регистрация: 25.04.2008
Сообщений: 827
С нами: 9497186

Репутация: 1304


По умолчанию

Зачем каждый раз парсить форму, особенно, когда он не меняется? Для логина на HWM надо передавать :

PHP код:
'LOGIN_redirect=1&login='.$login.'&lreseted=1&pass='.$passw.'&preseted=1&lbut.x=61&lbut.y=13' 
Вот для записи на работу - да, надо будет парсить страницу
 
Ответить с цитированием

  #4  
Старый 17.04.2009, 11:27
Gar|k
Постоянный
Регистрация: 20.03.2009
Сообщений: 564
С нами: 9023100

Репутация: 395


По умолчанию

rcc0023 учи регулярки... уже в 4 темах отвечал подобных
в одной даже очень подробно описал что да как...
 
Ответить с цитированием
Ответ



Предыдущая тема Следующая тема
Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Books PSalm69 Избранное 273 13.02.2016 01:24



Здесь присутствуют: 1 (пользователей: 0 , гостей: 1)
 


Быстрый переход




ANTICHAT ™ © 2001- Antichat Kft.