SHARE
TWEET

Untitled

a guest Feb 14th, 2020 75 in 350 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. function makeSlugs( $string, $separator = '-' )
  4. {
  5.     $accents_regex = '~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i';
  6.     $special_cases = array( '&' => 'and', "'" => '');
  7.     $string = mb_strtolower( trim( $string ), 'UTF-8' );
  8.     $string = str_replace( array_keys($special_cases), array_values( $special_cases), $string );
  9.     $string = preg_replace( $accents_regex, '$1', htmlentities( $string, ENT_QUOTES, 'UTF-8' ) );
  10.     $string = preg_replace("/[^a-z0-9]/u", "$separator", $string);
  11.     $string = preg_replace("/[$separator]+/u", "$separator", $string);
  12.     return $string;
  13. }
  14. function cepanje($prvi, $drugi, $html) {
  15.  
  16. if(strpos($html, $prvi) == false || strpos($html, $drugi) == false) {  $greska = 1; return $greska;}
  17.  
  18. $vracanje = explode($prvi, $html);
  19. if(strpos($vracanje[1], $drugi) == false) { $greska = 1; return $greska; }
  20.  
  21. $vracanje = explode($drugi, $vracanje[1]);
  22.  
  23. $vracanje = $vracanje[0];
  24.  
  25. return $vracanje;
  26.  
  27.  
  28. }
  29. include("db.php");
  30.  
  31.  
  32. $sql = "SELECT id,tagovi FROM gifovi ORDER BY RAND() LIMIT 1";
  33. $result = mysqli_query($conn, $sql);
  34. $row = mysqli_fetch_assoc($result);
  35. $tagovisearch = $row["tagovi"];
  36. $id = $row["id"];
  37. $tagovisearch = explode(',', $tagovisearch);
  38. $random_keys=array_rand($tagovisearch);
  39. $tagovisearch = $tagovisearch[$random_keys];
  40. echo "<h1>".$id." / ".$tagovisearch."</h1>";
  41. $html = file_get_contents("https://giphy.com/explore/".$tagovisearch);
  42. $delovi = explode("https://giphy.com/gifs/", $html);
  43. $x = 0;
  44. foreach($delovi as $deo) {
  45. if($x > 0) {
  46.  
  47. $delic = explode('",', $deo);
  48. $delic = explode("-", $delic[0]);
  49. $delic = end($delic);
  50.  
  51. $sql = "SELECT id FROM gifovi WHERE gifid = '$delic' LIMIT 1";
  52. $result = mysqli_query($conn, $sql);
  53. $row = mysqli_fetch_assoc($result);
  54. $id = $row["id"];
  55.  
  56. if(strlen($id) < 1) {
  57. $malihtml = file_get_contents("https://giphy.com/gifs/".$delic);
  58.  
  59.  
  60. $title = cepanje('<title>', ' - ', $malihtml);
  61.  
  62. $seourl = makeSlugs($title);
  63. $tagovi = cepanje('"tags": [', '],', $malihtml);
  64. $tagovi = str_replace('", "',",", $tagovi);
  65. $tagovi = str_replace('"',"", $tagovi);
  66. $tagovi = str_replace(' ',"-", $tagovi);
  67.  
  68.  $title = mysqli_real_escape_string($conn, $title);
  69. $tagovi = mysqli_real_escape_string($conn, $tagovi);
  70. $sql = "INSERT INTO gifovi (gifid, tagovi, seolink, title) VALUES ('$delic', '$tagovi', '$seourl', '$title')";
  71.  
  72. mysqli_query($conn, $sql);
  73. echo '<div>--'.$x.'//'.$delic.'//'.$title.'<b> Ubaceno!!!</b></div>';
  74.  
  75. }
  76. else { echo '<div>--'.$x.'//'.$delic.'//Ima Vec!!!</div>'; }
  77.  
  78. }
  79. $x = $x + 1;
  80. }
  81.  
  82. ?>
  83. <meta http-equiv="refresh" content="1">
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top