Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
482
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.10 KB | None | 0 0
  1. <?php
  2. set_time_limit(0);
  3. ignore_user_abort(1);
  4. function trim_replace($data){
  5. $a = trim($data);
  6. $a = str_replace('<', '', $a);
  7. $a = str_replace('>', '', $a);
  8. $a = str_replace('"', '', $a);
  9. $a = str_replace('`', '', $a);
  10. $a = str_replace('-', '', $a);
  11. return $a;
  12. }
  13. function GetTimeDiff($timestamp)
  14. {
  15. $how_log_ago = '';
  16. $seconds = $timestamp - time();
  17. $minutes = (int)($seconds / 60);
  18. $hours = (int)($minutes / 60);
  19. $days = (int)($hours / 24);
  20. if ($days >= 1) {
  21. $how_log_ago = $days . ' hari';
  22. } else if ($hours >= 1) {
  23. $how_log_ago = $hours . ' jam';
  24. } else if ($minutes >= 1) {
  25. $how_log_ago = $minutes . ' menit';
  26. } else {
  27. $how_log_ago = $seconds . ' detik';
  28. }
  29. return $how_log_ago;
  30. }
  31. function base_url($atRoot=FALSE, $atCore=FALSE, $parse=FALSE){
  32. if (isset($_SERVER['HTTP_HOST'])) {
  33. $http = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http';
  34. $hostname = $_SERVER['HTTP_HOST'];
  35. $dir = str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
  36.  
  37. $core = preg_split('@/@', str_replace($_SERVER['DOCUMENT_ROOT'], '', realpath(dirname(__FILE__))), NULL, PREG_SPLIT_NO_EMPTY);
  38. $core = $core[0];
  39.  
  40. $tmplt = $atRoot ? ($atCore ? "%s://%s/%s/" : "%s://%s/") : ($atCore ? "%s://%s/%s/" : "%s://%s%s");
  41. $end = $atRoot ? ($atCore ? $core : $hostname) : ($atCore ? $core : $dir);
  42. $base_url = sprintf( $tmplt, $http, $hostname, $end );
  43. }
  44. else $base_url = 'http://localhost/';
  45.  
  46. if ($parse) {
  47. $base_url = parse_url($base_url);
  48. if (isset($base_url['path'])) if ($base_url['path'] == '/') $base_url['path'] = '';
  49. }
  50.  
  51. return $base_url;
  52. }
  53. function paginasi($reload, $page, $tpages) {
  54. $adjacents = 2;
  55. $prevlabel = "&lsaquo; Prev";
  56. $nextlabel = "Next &rsaquo;";
  57. $out = '<ul class="pagination pagination-sm no-margin pull-left">';
  58. if ($page == 1) {
  59. $out.= "<li><a href=\"#\">$prevlabel</a></li>\n";
  60. } elseif ($page == 2) {
  61. $out.="<li><a href=\"".$reload."\">".$prevlabel."</a></li>\n";
  62. } else {
  63. $out.="<li><a href=\"".$reload."&page=".($page - 1)."\">".$prevlabel."</a></li>\n";
  64. }
  65. $pmin=($page>$adjacents)?($page - $adjacents):1;
  66. $pmax=($page<($tpages - $adjacents))?($page + $adjacents):$tpages;
  67. for ($i = $pmin; $i <= $pmax; $i++) {
  68. if ($i == $page) {
  69. $out.= "<li class=\"active\"><a href=\"#\">".$i."</a></li>\n";
  70. } elseif ($i == 1) {
  71. $out.="<li><a href=\"".$reload."\">".$i."</a></li>\n";
  72. } else {
  73. $out.="<li><a href=\"".$reload."&page=".$i."\">".$i."</a></li>\n";
  74. }
  75. }
  76.  
  77. if ($page<($tpages - $adjacents)) {
  78. $out.= "<li><a href=\"" . $reload."&page=".$tpages."\">" .$tpages."</a></li>\n";
  79. }
  80. if ($page < $tpages) {
  81. $out.= "<li><a href=\"".$reload."&page=".($page + 1)."\">".$nextlabel."</a></li>\n";
  82. } else {
  83. $out.= "<li><a href=\"#\">$nextlabel</a></li>\n";
  84. }
  85. $out.= "</ul>";
  86. return $out;
  87. }
  88. function proccess($ighost, $useragent, $url, $cookie = 0, $data = 0, $httpheader = array(), $proxy = 0, $userpwd = 0, $is_socks5 = 0){
  89. $url = $ighost ? 'https://i.instagram.com/api/v1/' . $url : $url;
  90. $ch = curl_init($url);
  91. curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
  92. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  93. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  94. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  95. curl_setopt($ch, CURLOPT_TIMEOUT, 20);
  96. if($proxy) curl_setopt($ch, CURLOPT_PROXY, $proxy);
  97. if($userpwd) curl_setopt($ch, CURLOPT_PROXYUSERPWD, $userpwd);
  98. if($is_socks5) curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
  99. if($httpheader) curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
  100. curl_setopt($ch, CURLOPT_HEADER, 1);
  101. if($cookie) curl_setopt($ch, CURLOPT_COOKIE, $cookie);
  102. if ($data):
  103. curl_setopt($ch, CURLOPT_POST, 1);
  104. curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  105. endif;
  106. $response = curl_exec($ch);
  107. $httpcode = curl_getinfo($ch);
  108. if(!$httpcode) return false; else{
  109. $header = substr($response, 0, curl_getinfo($ch, CURLINFO_HEADER_SIZE));
  110. $body = substr($response, curl_getinfo($ch, CURLINFO_HEADER_SIZE));
  111. curl_close($ch);
  112. return array($header, $body);
  113. }
  114. }
  115. function generate_useragent($sign_version = '6.22.0'){
  116. $resolusi = array('1080x1776','1080x1920','720x1280', '320x480', '480x800', '1024x768', '1280x720', '768x1024', '480x320');
  117. $versi = array('GT-N7000', 'SM-N9000', 'GT-I9220', 'GT-I9100'); $dpi = array('120', '160', '320', '240');
  118. $ver = $versi[array_rand($versi)];
  119. return 'Instagram '.$sign_version.' Android ('.mt_rand(10,11).'/'.mt_rand(1,3).'.'.mt_rand(3,5).'.'.mt_rand(0,5).'; '.$dpi[array_rand($dpi)].'; '.$resolusi[array_rand($resolusi)].'; samsung; '.$ver.'; '.$ver.'; smdkc210; en_US)';
  120. }
  121. function hook($data) {
  122. return 'ig_sig_key_version=4&signed_body=' . hash_hmac('sha256', $data, '469862b7e45f078550a0db3687f51ef03005573121a3a7e8d7f43eddb3584a36') . '.' . urlencode($data);
  123. }
  124. function ava_hook($bound, $csrf, $file_url) {
  125. $eol = "\r\n";
  126. $body = '';
  127. $body.= '--'.$bound. $eol;
  128. $body.= 'Content-Disposition: form-data; name="_csrftoken"' . $eol . $eol;
  129. $body.= $csrf . $eol;
  130. $body.= '--'.$bound. $eol;
  131. $body.= 'Content-Disposition: form-data; name="profile_pic"; filename="profile_pic"'. $eol;
  132. $body.= 'Content-Type: application/octet-stream'. $eol;
  133. $body.= 'Content-Transfer-Encoding: binary'. $eol. $eol;
  134. $body.= file_get_contents($file_url) . $eol;
  135. $body.= '--'.$bound .'--' . $eol. $eol;
  136. return $body;
  137. }
  138. function generate_device_id(){
  139. return 'android-' . md5(rand(1000, 9999)).rand(2, 9);
  140. }
  141. function generate_guid($tipe = 0){
  142. $guid = sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
  143. mt_rand(0, 65535),
  144. mt_rand(0, 65535),
  145. mt_rand(0, 65535),
  146. mt_rand(16384, 20479),
  147. mt_rand(32768, 49151),
  148. mt_rand(0, 65535),
  149. mt_rand(0, 65535),
  150. mt_rand(0, 65535));
  151. return $tipe ? $guid : str_replace('-', '', $guid);
  152. }
  153. function replace_friendship($teks, $tipe, $useragent, $cookies){
  154. preg_match('#_from_(.*?)_limit_#', $teks, $from);
  155. $ch = curl_init('https://www.instagram.com/'.$from[1].'/');
  156. curl_setopt($ch, CURLOPT_USERAGENT, 'Instagram 6.22.0 Android (16/4.1.2; 120dpi; 240x320; samsung; GT-S5282; mint; sp8810; in_ID)');
  157. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  158. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  159. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  160. $resp = curl_exec($ch);
  161. $httpcode = curl_getinfo($ch);
  162. curl_close($ch);
  163. if($httpcode['http_code']==200):
  164. preg_match('#","id":"(.*?)","biography":#',$resp,$idv);
  165. preg_match('#_limit_(.*?)::}#', $teks, $limit);
  166. $jumlah = (((int)$limit[1]-1)>10) ? 10 : ((int)$limit[1]-1);
  167. $list = array();
  168. $c = 0;
  169. do{
  170. $parameters = ($c>0) ? '?max_id='.$c : '';
  171. $req = proccess(1, $useragent, 'friendships/'.$idv[1].'/'.$tipe.'/'.$parameters, $cookies, null, array('Accept-Language: id-ID, en-US', 'X-IG-Connection-Type: WIFI'));
  172. $req = json_decode($req[1]);
  173. for($i=0;$i<count($req->users);$i++):
  174. if(count($list)<=$jumlah)
  175. $list[count($list)] = $req->users[$i]->username;
  176. endfor;
  177. $c = (isset($req->next_max_id)) ? $req->next_max_id : 0;
  178. }while(count($list)<=$jumlah);
  179. $mention_people = '';
  180. for($i=0;$i<count($list);$i++)
  181. $mention_people .= '@'.$list[$i].' ';
  182. preg_match('#{::(.*?)::}#',$teks,$teks1);
  183. return str_replace('{::'.$teks1[1].'::}', $mention_people, $teks);
  184. else:
  185. return false;
  186. endif;
  187. }
  188. function replace_media($teks, $tipe, $useragent, $cookies){
  189. preg_match('#_from_(.*?)_limit_#', $teks, $from);
  190. $ch = curl_init('https://api.instagram.com/oembed/?url=https://www.instagram.com/p/'.$from[1].'/');
  191. curl_setopt($ch, CURLOPT_USERAGENT, 'Instagram 6.22.0 Android (16/4.1.2; 120dpi; 240x320; samsung; GT-S5282; mint; sp8810; in_ID)');
  192. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  193. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  194. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  195. $resp = curl_exec($ch);
  196. $httpcode = curl_getinfo($ch);
  197. curl_close($ch);
  198. if($httpcode['http_code']==200):
  199. $resp = json_decode($resp);
  200. preg_match('#_limit_(.*?)::}#', $teks, $limit);
  201. $jumlah = (((int)$limit[1]-1)>10) ? 10 : ((int)$limit[1]-1);
  202. $list = array();
  203. $c = 0;
  204. if($tipe=='likers'):
  205. do{
  206. $req = proccess(1, $useragent, 'media/'.$resp->media_id.'/'.$tipe.'/', $cookies, null, array('Accept-Language: id-ID, en-US', 'X-IG-Connection-Type: WIFI'));
  207. $req = json_decode($req[1]);
  208. if($jumlah>count($req->users))
  209. $jumlah = count($req->users)-1;
  210. for($i=0;$i<count($req->users);$i++):
  211. if(count($list)<=$jumlah)
  212. $list[count($list)] = $req->users[$i]->username;
  213. endfor;
  214. }while(count($list)<=$jumlah);
  215. else:
  216. do{
  217. $parameters = ($c>0) ? '?max_id='.$c : '';
  218. $reqs = proccess(1, $useragent, 'media/'.$resp->media_id.'/'.$tipe.'/'.$parameters, $cookies, null, array('Accept-Language: id-ID, en-US', 'X-IG-Connection-Type: WIFI'));
  219. $req = json_decode($reqs[1]);
  220. if($jumlah>$req->comment_count)
  221. $jumlah = $req->comment_count-1;
  222. for($i=0;$i<count($req->comments);$i++):
  223. if(count($list)<=$jumlah)
  224. $list[count($list)] = $req->comments[$i]->user->username;
  225. endfor;
  226. preg_match('#"next_max_id":(.*?),"caption"#', $reqs[1], $max_id);
  227. if($max_id[1])
  228. $c = ($c==$max_id[1]) ? 0 : $max_id[1];
  229. else
  230. $c = 0;
  231. }while(count($list)<=$jumlah);
  232. endif;
  233. $mention_people = '';
  234. for($i=0;$i<count($list);$i++)
  235. $mention_people .= '@'.$list[$i].' ';
  236. preg_match('#{::(.*?)::}#',$teks,$teks1);
  237. return str_replace('{::'.$teks1[1].'::}', $mention_people, $teks);
  238. else:
  239. return false;
  240. endif;
  241. }
  242. function unicode_decode($str) {
  243. return preg_replace_callback("/\\\u([0-9a-f]{4})/i",
  244. create_function('$matches',
  245. 'return html_entity_decode(\'&#x\'.$matches[1].\';\', ENT_QUOTES, \'UTF-8\');'
  246. ), $str);
  247. }
  248. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement