Skip to content

Commit 8291b08

Browse files
authored
Update NetPHP.php
1 parent fadc7d4 commit 8291b08

1 file changed

Lines changed: 26 additions & 50 deletions

File tree

NetPHP.php

Lines changed: 26 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -14,79 +14,62 @@
1414
$debug_details=true;
1515
$debug_details=false;
1616
$token=null;
17-
function starts($haystack,$needle)
18-
{
17+
function starts($haystack,$needle) {
1918
$length = strlen($needle);
2019
return(substr($haystack,0,$length) === $needle);
2120
}
22-
function ends($haystack,$needle)
23-
{
21+
function ends($haystack,$needle) {
2422
$length = strlen($needle);
25-
if($length == 0)
26-
{
23+
if($length == 0) {
2724
return true;
2825
}
2926
return(substr($haystack,-$length) === $needle);
3027
}
31-
function contains($string,$contain)
32-
{
28+
function contains($string,$contain) {
3329
return strpos($string,$contain) !== false;
3430
}
35-
function useragent()
36-
{
31+
function useragent() {
3732
return "Mozilla/5.0 (Windows NT 6.1; r…) Gecko/20100101 Firefox/60.0";
3833
return "Mozilla/5.0(Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36(KHTML,like Gecko) curlrome/68.0.3440.106 Mobile Safari/537.36";
3934
}
40-
function store_token($response)
41-
{
35+
function store_token($response) {
4236
preg_match_all("/name=\"\_token\" value=\"(?<token>[^\"]+)\"/i",$response,$tokens);
43-
if(!isset($tokens["token"][0]))
44-
{
37+
if(!isset($tokens["token"][0])) {
4538
exit("No Token value in login page!\n");
4639
}
4740
return $tokens["token"][0];
4841
}
49-
function get_headers_from_curl_response($headerContent)
50-
{
42+
function get_headers_from_curl_response($headerContent) {
5143
$headers = array();
5244
$arrRequests = explode("\r\n\r\n",$headerContent);
53-
for($index = 0; $index < count($arrRequests) -1; $index++)
54-
{
55-
foreach(explode("\r\n",$arrRequests[$index]) as $i => $line)
56-
{
45+
for($index = 0; $index < count($arrRequests) -1; $index++) {
46+
foreach(explode("\r\n",$arrRequests[$index]) as $i => $line) {
5747
if($i === 0)
5848
$headers[$index]['http_code'] = $line;
59-
else
60-
{
49+
else {
6150
list($key,$value) = explode(': ',$line);
6251
$headers[$index][$key] = $value;
6352
}
6453
}
6554
}
6655
return $headers;
6756
}
68-
function post($url,$values,$headers=[],$reffer="",$auto_redirect=true)
69-
{
57+
function post($url,$values,$headers=[],$reffer="",$auto_redirect=true) {
7058
global $debug,$debug_details;
71-
if($debug)
72-
{
59+
if($debug) {
7360
print "@Request[POST]----------------------------------------------\n";
7461
print "----------@link ".$url."\n";
75-
if($debug_details)
76-
{
77-
if($reffer!="")
78-
{
62+
if($debug_details) {
63+
if($reffer!="") {
7964
print "----------@Reffer\n";
8065
print $reffer;
8166
print "\n";
8267
}
83-
if(count($values)!=0)
84-
{
68+
if(count($values)!=0) {
8569
print "----------@Values\n";
8670
print_r($values);
8771
}
88-
if(count($headers)!=0)
89-
{
72+
if(count($headers)!=0) {
9073
print "----------@Headers\n";
9174
print_r($headers);
9275
}
@@ -113,8 +96,7 @@ function post($url,$values,$headers=[],$reffer="",$auto_redirect=true)
11396
$header = substr($response,0,$header_size);
11497
$body = substr($response,$header_size);
11598
curl_close($curl);
116-
if($debug && $debug_details)
117-
{
99+
if($debug && $debug_details) {
118100
print "----------@Response Headers\n";
119101
print_r($header);
120102
print "----------@Response Body\n";
@@ -126,20 +108,16 @@ function post($url,$values,$headers=[],$reffer="",$auto_redirect=true)
126108
function get($url,$headers=[],$reffer="",$auto_redirect=true)
127109
{
128110
global $debug,$debug_details;
129-
if($debug)
130-
{
111+
if($debug) {
131112
print "@Request[GET]----------------------------------------------\n";
132113
print "----------@link ".$url."\n";
133-
if($debug_details)
134-
{
135-
if($reffer!="")
136-
{
114+
if($debug_details) {
115+
if($reffer!="") {
137116
print "----------@Reffer\n";
138117
print $reffer;
139118
print "\n";
140119
}
141-
if(count($headers)!=0)
142-
{
120+
if(count($headers)!=0) {
143121
print "----------@Headers\n";
144122
print_r($headers);
145123
}
@@ -165,8 +143,7 @@ function get($url,$headers=[],$reffer="",$auto_redirect=true)
165143
$header = substr($response,0,$header_size);
166144
$body = substr($response,$header_size);
167145
curl_close($curl);
168-
if($debug && $debug_details)
169-
{
146+
if($debug && $debug_details) {
170147
print "----------@Response Headers\n";
171148
print_r($header);
172149
print "----------@Response Body\n";
@@ -176,12 +153,11 @@ function get($url,$headers=[],$reffer="",$auto_redirect=true)
176153
return [$body,$header];
177154
}
178155
////////////////////////////////////////////////////////
179-
function random()//like Math.random() in JS
180-
{
156+
function random() {
157+
// like Math.random() in JS
181158
return(float)rand()/(float)getrandmax();
182159
}
183-
function get_parse($content,$name)
184-
{
160+
function get_parse($content,$name) {
185161
//name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value=""
186162
preg_match('/name="'.$name.'" id="'.$name.'" value="(?<value>[^\"]+)"/i',$content,$values);
187163
// print_r($values);

0 commit comments

Comments
 (0)