Advertisement
aliakbarbeda2

loop.php

Mar 19th, 2022
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. <?php
  2. //unlink('sudah.txt');
  3. $data = file_get_contents('bersih.txt');
  4. $pecah = explode('|',$data);
  5.  
  6. $sudah = file_get_contents('sudah.txt');
  7.  
  8. $myfile = fopen("sudah.txt", "w") or die("Unable to open file!");
  9. $jumlah = substr_count($sudah,'|');
  10. $tambah = $jumlah+100;
  11. //echo 'jumlah | = '.$jumlah.' jumlah+10 = '.$tambah.'<br/>';
  12.  
  13.  
  14. for ($x = $jumlah; $x <= $tambah; $x++) {
  15. $pecah[$x] = str_replace('|','',$pecah[$x]);
  16. if(substr_count($sudah,''. $pecah[$x].'|')>0){
  17. //tidak tulis dan tidak eksekusi karena lebih 0 sudah ada di udah.txt
  18. //echo ''.$pecah[$x].' sudah ada di sudah.txt<br/>';
  19. $txt = "";
  20. fwrite($myfile, $txt);
  21. }
  22. else {
  23. //jika belum ada maka jalanka untuk tambah ke sheet dan tulis ke sudah.txt
  24. //echo ''.$pecah[$x].' belum ada<br/>';
  25.  
  26. $txt = "".$pecah[$x]."|";
  27. // $ch = curl_init("https://script.google.com/a/sman-modalbangsa.sch.id/macros/s/AKfycbxnFvNqcwftcO_cymNzkhaGTQgyKEJKKeoFdJlGLNSJ/dev?bali="+$pecah[$x]+"");
  28.  
  29. // curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  30. // curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
  31. // $content = curl_exec($ch);
  32. // curl_close($ch);
  33.  
  34. // echo $content;
  35. $go = file_get_contents("https://script.google.com/a/sman-modalbangsa.sch.id/macros/s/AKfycbxnFvNqcwftcO_cymNzkhaGTQgyKEJKKeoFdJlGLNSJ/dev?bali="+$pecah[$x]+"");
  36.  
  37.  
  38. fwrite($myfile, $txt);
  39. $pecah[$x] = str_replace(' ','_',$pecah[$x]);
  40. $pecah[$x] = ucfirst($pecah[$x]);
  41. echo ''.$pecah[$x].'|';
  42.  
  43. }
  44. }
  45. $txt = "".$sudah."";
  46.  
  47. fwrite($myfile, $txt);
  48. fclose($myfile);
  49. ?>
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement