Advertisement
Guest User

Untitled

a guest
Dec 11th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. <?php
  2. include dirname(__FILE__).'/../../vendor/autoload.php';
  3.  
  4. // API USAGE | POST GET ALLOWED
  5. // add-profile.php?url=https://www.instagram.com/evieeffendie/&jumlah=100
  6.  
  7. class AddProfile
  8. {
  9. protected $url;
  10.  
  11. protected $jumlah;
  12.  
  13. public function __construct($url, $jumlah)
  14. {
  15. $this->expired = date("Y-F-d", strtotime("+30 days"));
  16. $this->url = $url;
  17. $this->jumlah = $jumlah;
  18. $this->profileFileLocation = dirname(__FILE__).'/../Profile.txt';
  19. $this->history = dirname(__FILE__).'/../History.txt';
  20. }
  21.  
  22. public function run()
  23. {
  24. // empty check
  25. if (empty($this->url) || empty($this->jumlah)) {
  26. return false;
  27. }
  28.  
  29. $profileArray = explode("\n", file_get_contents($this->profileFileLocation));
  30. $profileArray[] = $this->url.'|'.$this->jumlah;
  31. $profileArray = array_filter($profileArray);
  32. return file_put_contents($this->profileFileLocation, implode("\n", array_unique($profileArray)));
  33. }
  34.  
  35. public function history()
  36. {
  37. $historyArray = explode("\n", file_get_contents($this->history));
  38. $historyArray[] = $this->url.' - '.$this->expired;
  39. $historyArray = array_filter($historyArray);
  40. return file_put_contents($this->history, implode("\n", array_unique($historyArray)));
  41. }
  42. }
  43.  
  44. $api = new AddProfile($_REQUEST['url'], $_REQUEST['jumlah']);
  45. $api->run();
  46. $api->history();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement