Jump to content

murfy

Members
  • Posts

    47
  • Joined

  • Last visited

Everything posted by murfy

  1. Also I would like to ask you how to send request simulation input checked but the inputs have all same name: <input type="checkbox" checked="checked" value="0" name="pr[]"> <input type="checkbox" checked="checked" value="1" name="pr[]"> <input type="checkbox" checked="checked" value="2" name="pr[]"> <input id="ports" type="checkbox" checked=""> How to send that I want first checkbox check, second and third not checked, next checked?
  2. BTW: I have messured the time how long it taken to download the file: with curl action taken 3.12357401848 s, with php it takes just 1.59751701355 s. PHP download looks 2x faster then curl.
  3. Nice. So basicly all what is needed is to set the loop? And the n bytes number in the fread should be 4096? It cannot be bigger?
  4. U R right. It works. But how can I do filesize messuring? 160 kB is still pretty short. $url="http://www.iplocation.net/index.php"; $fp = fopen($url, "r", false, $context); $meta = stream_get_meta_data($fp); $content=fread($fp, filesize($url)); fread obtains 0 length on parameter 2. The command stream_get_meta_data() is always neccessary to perform before I can read th file? Looks like $content=fread($fp, 500000); still downloads only 5kB of data, don't you thing? But table with location should be downloaded.
  5. jazzman1: It was to me explained that there are two codes doing the same thing. So I understood that I must to try them separated. So they worked. And now I tried to use curl to send a form data and download page. I have succeeded to do that. But now I would like to do the same with php and here I fail. Enter some IP you want to locate: $context = stream_context_create(array('http' => array( 'method' => 'POST', 'header' => 'Content-Type: application/x-www-form-urlencoded', 'content' => http_build_query(array('query' => '71.44.87.55')) ))); $fp = fopen("http://www.iplocation.net/index.php", "r", false, $context); $meta = stream_get_meta_data($fp); $headers = $meta["wrapper_data"]; print_r($headers); $content=fread($fp, 8000); fclose($fp); echo $content; It waited too long so nothing downloaded. What's wrong?
  6. It seems like you don't understand what I want. I need to learn to use cookies in CURL but this is example page, where I wanted to test it. Also the other codes I tried did not work at all. Where is the problem? I want to make my codes working and do what is expected.
  7. I want to ask you how to send headers to simulate the cookies which keeps values of options and then to download the file. For example If I would like to insert IP here: http://www.iplocation.net/index.php and then download the file how to do it? I have read one article, where is this code http://paste.ofcode.org/bfFL99ZZHKxk3VUmZcB4xe But it did not anything. Also I have tried to change the above code to this: http://paste.ofcode.org/JwSvGFPyhPESkUHD9VLedf to test the options saved in cookies. But nothing works (no data displayed and no file downloaded). What I do wrong?
  8. I see no error in the code, the testing page (see link above) fails to print it correctly. Problem solved.
  9. preg_match_all("@(?<=style=\"display: inline\">)\d{1,3}(?=\.?<)@", $subject, $matches, PREG_OFFSET_CAPTURE, 0); Should return values 113 , 30 and 111 , 96 in the array. How to correct this?
  10. Hello I need help with this reg. exp. for preg_match_all @(?<=style=\"display: inline\">)\d{1,3}(?=\.?<)@ Subject: <span style="display: inline">113</span><span class="qazL">.</span><span style="display: inline">111</span Returns: array ( 0 => array ( 0 => '113', 1 => 30, ), ) Should return values 113 and 111 in the array. How to correct this? Tested here: http://www.functions-online.com/preg_match.html
  11. I read data from binary file which contains names of domains separated by semicolon. I have saved one word "localhost;" into the position. I tried more versions, the main difference is with the use of last condition of the while loop: $word=$byte=""; fseek( $fh , $n );echo "n is $n;"; while ( $byte=fread($fh,1) && bindec($byte)!=59) // semicolon is ord 59 ... && ord($byte)!=0 { echo "<b>".$byte."</b>"; $word.=$byte; } echo ":$word==".$_SERVER["HTTP_HOST"]."<br>".ord($byte); if ( $word==$_SERVER["HTTP_HOST"] ) return false; // this domain is blocked First of all I tried this: while ( $byte=fread($fh,1) && $byte!=";") none works: while ( $byte=fread($fh,1) && chr($byte)!=";") also no success: while ( $byte=fread($fh,1) && ord($byte)!=";") It should print localhost==localhost ... however I am getting number one instead (repeated ). If I will skip the last condition, the localhost is printed commonly with the rest of the file (but I need to break it). Any idea what I do wrong?
  12. Of sure your solution is simple and I also use it for different things. But it's true that I did not do any real site for real traffic using RS. I would like to do one site with RS and use there the IP container. But because IP list is demanded to be offten readed and offen searched for exact item (comparison two items) so I thought it could be good idea. It is not problem to me to make the class. When you realize that sites which uses RS contains many classes, so one more class is just a simple thing. Because to me it looks much more complicated to think up and realize class for mysql or for management of the web content than to do this simple class. I know it can look complicated because it has methods, but this is exactly what I see as advantage. Classes benefit is that they bring more readability to the code... Of sore, reading a simple file is very short code, but also you must read and compare much more data... I am not sure If I mentioned the concept of the container. I have reserved 250 bytes for three numbers of IP, which is 750 per a "row". So when you have IP 124.1.2.3 then I find the row 124 which is on position 750*124 - 1. The row of 750 is divided to 250 because 250 for second number, 250 for third number and 250 for fourth number. Now when I search for IP I have two approches and I must decide which one is better? A) either read first byte of the row (1st byte of the 1st segment:i) and then compare it with the second number of IP. If this is equal, so I seek for the second segment first byte (i+500) and compare with third number. If it is equal, so I do the same for the fourth number (i=750). I can repeat it as many times as needed. Of sure, that if there is not equality, than is will not be returned false (existing item). This means, that it will skip most of the bytes. I think there should be about 3-10 IPS in every row, so I read about cca 5-30 bytes only. But the problem here can be the fseek, which mean often to change the position to read. B) another solution would be to read all 3 segments to variables $a=fread($fh,250);$b=fread($fh,250);$c=fread($fh,250); and then when they are in RAM memory do quick comparison with for loop. This would also read about 5-30 bytes, but the difference is that it would read whole 750 bytes and fseek would be called only 1x. So what approach could be better? What do you think?
  13. Solved: This is error of the viewer. Notepad++ Hexa editor does not show the BOM and shows correct positions of bytes.
  14. Also, can you help with this? I found that when I write a byte it uses two bytes instead one: so the number 64 should be correctly in the blue circle. There should be 7864 5E3C because here I have inserted 4 numbers: 120, 100 and 94, 60. So the result is like it uses Unicode because ot the unicode BOM which is on the begin of file. How should I create the file without the BOM, to have standard binary file behaviour? This is strange. I created the file with xb option and then added the string like this: fwrite($fh,$t); Yet I did a check of length die(strlen($t).""); // 750*254=190500 is OK. This looks like the buffer size is correct but still, why it is written in wrong way?
  15. Also if the fseek makes it slow I can change it to read all three segments of 250 bytes and then loop it in RAM memory.
  16. 1) I don't know if the BOM mark is a corruption when it is there in binary file. I have no idea how it was generated. 2) When the BOM mark disapears it could be taken as a corruption of BOM mark 3) Yes, the 0000 data disapear till the end of file, so this is corruption too I wanted to do it binary to gain a speedy approach. The first write to this file should have about 120-140 IPs and then just adding few IPs per minute would be nice. I know I could simply add it to txt file, but then when I would want to make sure that the IP is not in the list I would need to search whole file if it contains the IP. Why do you think that simple file solution would be better performance? This is ideal I think, I just jump to one segment to check if some IP is there. In the moment I have working class but it writes only 3 bytes of the first IP, and the next IP corrupts the file, so I want to find the cause today. Hopefully I will solve it today. Do you think that file seeking is slower because it is on hard drive than search in heap which is in RAM?
  17. Thanks for this piece of code, can be useful. But did you see the file to be corrupted or not? Can you find the reason why it corrupts? In recent post I have added the second version, which is working, so I would like to know if you noticed same problem like me.
  18. Yet I show you working version which is simplified. This uses no class: http://paste.ofcode.org/8ipwC6eWGPxZpHGK5DQFmg so you can see how it works. The written data do not corrupt the file. But why I cannot use the class to do that?
  19. I don't know about this, how this happened. I edited the post only.
  20. I created a class which should creates new binary file (called 4.ip) in the case that the file does not exist. Method reset() does the job. Then I try to add some numbers from Ip to the file. I try to use binary mode but It looks like it corrupts the file. First value 0E is written correctly. I have marked the BOM which was created in the reset method (idk if is this right when it should be binary file. To see the above, uncomment the die(); on line 413. Then to see the bellow, comment it back. When I try to write the second value (line 415), the file looks corrupted, and all the 0000 disappear. This is the source code: http://paste.ofcode.org/v8M4DwrH7hQzkJMEDjaRpt please see the lines 412-418. <?php include("scan_ips_class.php"); $scanIPs = new Scan_ips; ?> Please help because I really cannot find out solution, and I am lost. Trying to solve this few days.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.