Advertisement
raul3k

GenerateLinks

Sep 15th, 2012
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.65 KB | None | 0 0
  1. <?php
  2. //die('ALREADY GENERATED');
  3.  
  4. set_time_limit(0);
  5. define('_PATH', 'links/');
  6. $links_gerados = array();
  7.  
  8. $num_to_generate = 2000;
  9. $gerados = 0;
  10. $to_repeat = array();
  11.  
  12. while($gerados <= $num_to_generate)
  13. {
  14.     if(count($links_gerados) == 10)
  15.     {
  16.         $string = implode("\r\n", $links_gerados);
  17.         write_file($string);
  18.         $string = '';
  19.         $links_gerados = array();
  20.     }
  21.     $link = generate_link();
  22.     $links_gerados[] = $link;
  23.     $gerados++;
  24.    
  25.     if($gerados % 5)
  26.     {
  27.         $to_repeat[] = $link;
  28.     }
  29. }
  30. if(count($to_repeat) > 0)
  31. {
  32.     $repeated = array();
  33.     $generated = 0;
  34.     foreach($to_repeat as $_link)
  35.     {
  36.         if(count($repeated) == 30)
  37.         {
  38.             $string = implode("\r\n", $repeated);
  39.             write_file($string);
  40.             $string = '';
  41.             $repeated = array();
  42.         }
  43.         $repeated[] = $_link;
  44.     }
  45. }
  46.  
  47. echo 'Links gerador: ' . $gerados;
  48. function get_total_links()
  49. {
  50.     return mt_rand(5, 10);
  51. }
  52.  
  53. function generate_link()
  54. {
  55.     $get = array('h=', 's=', 'f=', 'hg=', 'source=');
  56.     $get_value = array('hg', mt_rand(0,127), 's', 'valid', mt_rand(128,256));
  57.     $link = 'http://www.google.com/?';
  58.     $link .= $get[mt_rand(0, count($get)-1)];
  59.     $link .= $get_value[mt_rand(0, count($get_value)-1)];
  60.     $link .= '&';
  61.     $link .= $get[mt_rand(0, count($get)-1)];
  62.     $link .= $get_value[mt_rand(0, count($get_value)-1)];
  63.     $link .= '&';
  64.     $link .= $get[mt_rand(0, count($get)-1)];
  65.     $link .= $get_value[mt_rand(0, count($get_value)-1)];
  66.    
  67.     return $link;
  68. }
  69.  
  70. function write_file($string)
  71. {
  72.     $h = fopen(_PATH . generate_file_name(), 'w+');
  73.     $f = fwrite($h,$string);
  74.     fclose($h);
  75.     return $f;
  76. }
  77.  
  78. function generate_file_name()
  79. {
  80.     return 'Link' . mt_rand(0,255) . mt_rand(0,128) . '.txt';
  81. }
  82. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement