<commit_before><?php
  require_once "http.php";
  require_once "web_browser.php";
  require_once "simple_html_dom.php";
  
  $html = new simple_html_dom();
  $url = "http://wallbase.cc/toplist?section=wallpapers&q=&res_opt=eqeq&res=0x0&thpp=32&purity=000&board=21&aspect=0.00&ts=3d";
  $web = new WebBrowser();
  
  
  $result = $web->Process($url);

  //error handling
  if (!$result["success"])
    echo "Error retrieving URL.  " . $result["error"] . "\n";
  else if ($result["response"]["code"] != 200)
    echo "Error retrieving URL.  Server returned:  " . $result["response"]["code"] . " " . $result["response"]["meaning"] . "\n";
  //actual stuff
  else
  {
    //load page body to html 'object'
    $html->load($result["body"]);
    
    //extract all urls
    $links = $html->find("a[href]");
    
    $goodlinks=array();
    
    foreach($links as $link){
      if(strpos($link->href,"http://wallbase.cc/wallpaper/")!==false)
        $goodlinks[]=$link->href;
    }
    
    foreach($goodlinks as &$gl){
      $gl=split("[\/]",$gl)[4];
    }
    
    $random = mt_rand(0,count($goodlinks));
    shell_exec('wget http://wallpapers.wallbase.cc/rozne/wallpaper-'.$goodlinks[$random].'.jpg -O /home/victor/.wallpapers/lockscreen.jpg');
    shell_exec('wget http://wallpapers.wallbase.cc/rozne/wallpaper-'.$goodlinks[$random].'.jpg -O /home/victor/.wallpapers/old/'.date('Y-m-d_H:i:s').'-wallpaper-'.$goodlinks[$random].'.jpg');
    
  }
?><commit_msg>fixed the possibility of duplicates<commit_after><?php
  require_once "http.php";
  require_once "web_browser.php";
  require_once "simple_html_dom.php";
  
  $html = new simple_html_dom();
  $url = "http://wallbase.cc/toplist?section=wallpapers&q=&res_opt=eqeq&res=0x0&thpp=32&purity=000&board=21&aspect=0.00&ts=3d";
  $web = new WebBrowser();
  
  
  $result = $web->Process($url);

  //error handling
  if (!$result["success"])
    echo "Error retrieving URL.  " . $result["error"] . "\n";
  else if ($result["response"]["code"] != 200)
    echo "Error retrieving URL.  Server returned:  " . $result["response"]["code"] . " " . $result["response"]["meaning"] . "\n";
  //actual stuff
  else
  {
    //load page body to html 'object'
    $html->load($result["body"]);
    
    //extract all urls
    $links = $html->find("a[href]");
    
    $goodlinks=array();
    
    foreach($links as $link){
      if(strpos($link->href,"http://wallbase.cc/wallpaper/")!==false)
        $goodlinks[]=$link->href;
    }
    
    foreach($goodlinks as &$gl){
      $gl=split("[\/]",$gl)[4];
    }
    
    $random = mt_rand(0,count($goodlinks));
    $used = preg_split('/\s/',trim(shell_exec('ls /home/victor/.wallpapers/old/ | grep '.$goodlinks[$random])));
    do {
        $random = mt_rand(0,count($goodlinks));
        $used = preg_split('/\s/',trim(shell_exec('ls /home/victor/.wallpapers/old/ | grep '.$goodlinks[$random])));
    } while (empty($used[0])!=1);
    
    shell_exec('wget http://wallpapers.wallbase.cc/rozne/wallpaper-'.$goodlinks[$random].'.jpg -O /home/victor/.wallpapers/lockscreen.jpg');
    shell_exec('wget http://wallpapers.wallbase.cc/rozne/wallpaper-'.$goodlinks[$random].'.jpg -O /home/victor/.wallpapers/old/'.date('Y-m-d_H:i:s').'-wallpaper-'.$goodlinks[$random].'.jpg');
    
  }
?>
{'fraction_non_alphanumeric': 0.21993865030674847, 'fraction_numerical': 0.01196319018404908, 'mean_word_length': 3.4793956043956045, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1288491', 'n_tokens_mistral': 1225, 'n_tokens_neox': 1194, 'n_words': 169}