Advertisement
cyber_Ahn

lib

Mar 30th, 2015
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 10.27 KB | None | 0 0
  1. <?php
  2. //________________________________________________________________
  3.  
  4. error_reporting(0);
  5.  
  6. //________________________________________________________________
  7. function del_array($cach_delB,$delete)
  8. {
  9. $count = 0;
  10. foreach($cach_delB as $check)
  11. {
  12. if($check == $delete)
  13. {
  14. unset($cach_delB[$count]);
  15. }
  16. $count++;
  17. }
  18. return $cach_delB;
  19. }
  20. //________________________________________________________________
  21. function get_sim_uuid($simname)
  22. {
  23. $simname = urlencode($simname);
  24. $web = "http://api.gridsurvey.com/simquery.php?region=$simname&item=objects_uuid";
  25. $uuid_ans = getPage($web);
  26. return $uuid_ans;
  27. }
  28. //________________________________________________________________
  29. function generate_network_id($model)
  30. {
  31. $first = random_string($length = 3, $characters_array = false, $mode = 0, $test_mode = false);
  32. $secound = random_string($length = 3, $characters_array = false, $mode = 10, $test_mode = false);
  33. $back = "$first-$secound";
  34. return $back;
  35. }
  36. //________________________________________________________________
  37. function gen_zahlen($min, $max, $anz)
  38. {
  39. $werte = range($min, $max);
  40. mt_srand ((double)microtime()*1000000);
  41. for($x = 0; $x < $anz; $x++)
  42. {
  43. $i = mt_rand(1, count($werte))-1;
  44. $erg[] = $werte[$i];
  45. array_splice($werte, $i, 1);
  46. }
  47. return $erg;
  48. }
  49. //________________________________________________________________
  50. function random_string($length, $characters_array, $mode, $test_mode)
  51. {
  52.     if (!$characters_array)
  53.     {
  54.         $characters_array = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
  55.             'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y',
  56.             'Z');
  57.     }
  58.     if (!isset($mode))
  59.     {
  60.         $mode = 5;
  61.     }
  62.     $num = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9');
  63.     $random = '';
  64.     for ($i = 0; $i < $length; $i++)
  65.     {
  66.         if (rand(1, 10) > $mode)
  67.         {
  68.             $random .= $characters_array[rand(0, count($characters_array) - 1)];
  69.         }
  70.         else
  71.         {
  72.             $random .= $num[rand(0, 9)];
  73.         }
  74.     }
  75.     if ($test_mode)
  76.     {
  77.         //----- Random Test Mode -----
  78.         $test_array = str_split($random);
  79.         $i = 0;
  80.         $x = 0;
  81.  
  82.         foreach ($test_array as $key => $value)
  83.         {
  84.             if (is_numeric($value))
  85.             {
  86.                 $i++;
  87.             }
  88.             else
  89.             {
  90.                 $x++;
  91.             }
  92.         }
  93.         return $random.' - '.count($test_array).' Zeichen, '.$i.' Zahle(n), '.$x.' Buchstabe(n)';
  94.     }
  95.     else
  96.     {
  97.         return $random;
  98.     }
  99. }
  100. //________________________________________________________________
  101. function spam_x($data)
  102. {
  103. $count_r = "0";
  104. $time_r = "0";
  105. $set="no";
  106. include ("cwdata.php");
  107. $query = "SELECT * FROM spam_x";
  108. $result = mysql_query($query);
  109. while ($line = mysql_fetch_array($result))
  110. {
  111. if($data==$line[datax])
  112. {
  113. $set="yes";
  114. $time_r = $line[timex];
  115. $count_r = $line[countx];
  116. }
  117. }
  118. mysql_free_result($result);
  119. mysql_close();
  120. if($set=="no")
  121. {
  122. $time = time();
  123. $count = "1";
  124. include ("cwdata.php");
  125. mysql_query("INSERT INTO spam_x(id,datax,timex,countx)VALUES(NULL ,'$data','$time','$count')");
  126. mysql_close();
  127. $out = "run";
  128. }
  129. elseif($set=="yes")
  130. {
  131. $time_is = time();
  132. $time_be = $time_is - $time_r;
  133. if($time_be >= 30)
  134. {
  135. $out = "run";
  136. $count_r = "0";
  137. include ("cwdata.php");
  138. $aendern = "UPDATE spam_x Set
  139. timex = '$time_is', countx = '$count_r'
  140. WHERE datax = '$data'";
  141. $update = mysql_query($aendern);
  142. mysql_close();
  143. }
  144. elseif($count_r <= 2)
  145. {
  146. $out = "run";
  147. $count_r = $count_r + 1;
  148. include ("cwdata.php");
  149. $aendern = "UPDATE spam_x Set
  150. countx = '$count_r'
  151. WHERE datax = '$data'";
  152. $update = mysql_query($aendern);
  153. mysql_close();
  154. }
  155. elseif($count_r >= 3)
  156. {
  157. $out = "banned";
  158. }
  159. }
  160. return $out;
  161. }
  162. //________________________________________________________________
  163. function unixtotime($unix)
  164. {
  165. $datum = date("d.m.Y",$unix);
  166. $uhrzeit = date("H:i:s",$unix);
  167. $out = $datum."-".$uhrzeit;
  168. return $out;
  169. }
  170. //________________________________________________________________
  171. function getdiffdate($is,$old)
  172. {
  173. $exp_is_a = explode("-",$is);
  174. $exp_is_date = explode(".",$exp_is_a[0]);
  175. $exp_is_time = explode(":",$exp_is_a[1]);
  176. $exp_old_a = explode("-",$old);
  177. $exp_old_date = explode(".",$exp_old_a[0]);
  178. $exp_old_time = explode(":",$exp_old_a[1]);
  179. $time_is = mktime($exp_is_time[0],$exp_is_time[1],0,$exp_is_date[1],$exp_is_date[0],$exp_is_date[2]);
  180. $time_old = mktime($exp_old_time[0],$exp_old_time[1],0,$exp_old_date[1],$exp_old_date[0],$exp_old_date[2]);
  181. $diff=$time_old-$time_is;
  182. $x=$diff/86400;
  183. $weeks = 0;
  184. $days = 0;
  185. $w = "week";
  186. $d = "day";
  187. $h = "hour";
  188. $hour = 0;
  189. $min = 0;
  190. if($x > 6.9)
  191. {
  192. $weeks = $x/7;
  193. $expw = explode(".",$weeks);
  194. $weeks = $expw[0];
  195. $cacha = $weeks*7;
  196. $cachb = $x-$cacha;
  197. $expd = explode(".",$cachb);
  198. $days = $expd[0];
  199. $cachc = $cacha + $days;
  200. $cachd = $x * 24;
  201. $cache = $cachc *24;
  202. $cachf = $cachd -$cache;
  203. $exph = explode(".",$cachf);
  204. $hour = $exph[0];
  205. $cachh = $cachf-$hour;
  206. $cachi = $cachh * 60;
  207. $expmi = explode(".",$cachi);
  208. $min = $expmi[0];
  209. }
  210. elseif($x<7)
  211. {
  212. $cachz=$diff/86400;
  213. $expd = explode(".",$cachz);
  214. $days = $expd[0];
  215. $cachd = $x * 24;
  216. $cache = $days *24;
  217. $cachf = $cachd-$cache;
  218. $exph = explode(".",$cachf);
  219. $hour = $exph[0];
  220. $cachh = $cachf-$hour;
  221. $cachi = $cachh * 60;
  222. $expmi = explode(".",$cachi);
  223. $min = $expmi[0];
  224. }
  225. $m = "min";
  226. $months = 0;
  227. if($weeks > 3)
  228. {
  229. $months = $weeks/4;
  230. $expf = explode(".",$months);
  231. $months = $expf[0];
  232. $cachf = $months*4;
  233. $weeks = $weeks-$cachf;
  234. }
  235. $mm = "month";
  236. if($days > 1)
  237. {
  238. $d = $d."s";
  239. }
  240. if($weeks > 1)
  241. {
  242. $w = $w."s";
  243. }
  244. if($hour > 1)
  245. {
  246. $h = $h."s";
  247. }
  248. if($months > 1)
  249. {
  250. $mm = $mm."s";
  251. }
  252. $out_new = $months.$mm." ".$weeks.$w." ".$days.$d." ".$hour.$h." ".$min.$m;
  253. return $out_new;
  254. }
  255. //__________________________________________________________
  256. function getnewdata($adw,$olddate)
  257. {
  258. $expx = explode("-",$olddate);
  259. $new_datum = date("d.m.Y", strtotime("$expx[0] + $adw week"));
  260. $timest = "$new_datum-$expx[1]";
  261. return $timest;
  262. }
  263. //__________________________________________________________
  264. function getPage($web)
  265. {
  266. $html = "";
  267. $ch = curl_init($web);
  268. curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.12) Gecko/20070508 Firefox/1.5.0.12");
  269. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  270. curl_setopt($ch, CURLOPT_HEADER, 0);
  271. //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  272. curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
  273. curl_setopt($ch, CURLOPT_TIMEOUT, 15);
  274. $html = curl_exec($ch);
  275. if(curl_errno($ch))
  276. {
  277. $html = "";
  278. }
  279. curl_close ($ch);
  280. return $html;
  281. }
  282. //__________________________________________________________
  283. function slProfil($url, $type)
  284. {
  285. $data="";
  286. if($type == "image")
  287. {
  288. $cach = getPage($url);
  289. $data = getBetween($cach,'<img alt="profile image" src="','" class="parcelimg" />');
  290. }
  291. if($type == "displayname")
  292. {
  293. $cach = getPage($url);
  294. $data = getBetween($cach,'<html xmlns="http://www.w3.org/1999/xhtml">
  295. <head>
  296. <title>','</title>');
  297. }
  298. if($type == "age")
  299. {
  300. $cach = getPage($url);
  301. $data = getBetween($cach,'<p class="info"><span class="syscat">Resident Since:</span>
  302. ',')
  303. </p>');
  304. }
  305. return $data;
  306. }
  307. //________________________________________________________________
  308. function encodesearchurlprofil($name)
  309. {
  310. $key = name2Key($name);
  311. $url = 'http://world.secondlife.com/resident/'.$key;
  312. return $url;
  313. }
  314. //________________________________________________________________
  315. function getBetween($content,$start,$end)
  316. {
  317. $a1 = strpos($content,$start);
  318. $content = substr($content,$a1 + strlen($start));
  319. while($a2 = strrpos($content,$end))
  320. {
  321. $content = substr($content,0,$a2);
  322. }
  323. return $content;
  324. }
  325. //__________________________________________________________
  326. function sendToHost($host,$method,$path,$data,$useragent=0)
  327. {
  328. $fp = fsockopen($host, 80, $errno, $errstr, 30);
  329. if( !$fp )
  330. {
  331. echo"$errstr ($errno)<br />\n";
  332. }
  333. else
  334. {
  335. fputs($fp, "$method $path HTTP/1.1\r\n");
  336. fputs($fp, "Host: $host\r\n");
  337. fputs($fp, "Content-type: text/xml\r\n");
  338. fputs($fp, "Content-length: " . strlen($data) . "\r\n");
  339. if ($useragent)
  340. fputs($fp, "User-Agent: MSIE\r\n");
  341. fputs($fp, "Connection: close\r\n\r\n");
  342. fputs($fp, $data);
  343. fclose($fp);
  344. }
  345. }
  346. //__________________________________________________________
  347. function send_mail_sl($regard,$data,$uuid)
  348. {
  349. $addressor = "creator@caworks-sl.de";
  350. $receiver = "$uuid@lsl.secondlife.com";
  351. $mailtext = $data;
  352. mail($receiver, $regard, $mailtext, "From: $addressor ");
  353. }
  354. //__________________________________________________________
  355. function name2Key($name)
  356. {
  357. $SL_SEARCH = 'http://vwrsearch.secondlife.com/client_search.php?session=00000000-0000-0000-0000-000000000000&q=';
  358. $sName = split(' ',$name);
  359. $data = getPage($SL_SEARCH.$sName[0].'%20'.$sName[1]);
  360. $uuid = getBetween($data,'<h3 class="result_title">
  361.          <a href="http://world.secondlife.com/resident/','" >');
  362. if(!preg_match("/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/",$uuid)) $uuid = '00000000-0000-0000-0000-000000000000';
  363. return $uuid;
  364. }
  365. //__________________________________________________________
  366. function rand_char($chars)
  367. {
  368. $n = rand(0,(strlen($chars)-1));
  369. return $chars[$n];
  370. }
  371. //__________________________________________________________
  372. function id_filter($web)
  373. {
  374. if($web == "")
  375. {
  376. $zeichen = "0123456789abcdef";
  377. for($x=0;$x<3;$x++)
  378. {
  379. $s2 .= rand_char($zeichen);
  380. }
  381. for($x=0;$x<3;$x++)
  382. {
  383. $s3 .= rand_char($zeichen);
  384. }
  385. }
  386. else
  387. {
  388. $s1 = explode("-",$web);
  389. $s2 = substr($s1[0], 0, 3);
  390. $s3 = substr($s1[0], 3, 3);
  391. }
  392. $s2 = strtr($s2, "abcdef", "ABCDEF");
  393. $s3 = strtr($s3, "abcdef", "ABCDEF");
  394. $s2 = strtr($s2, "0123456789", "PPPPPPMMMM");
  395. $s2 = strtr($s2, "ABCDEF", "PPPMMM");
  396. $s3 = strtr($s3, "ABCDEF", "123456");
  397. return $s2."-".$s3;
  398. }
  399. //__________________________________________________________
  400. function send_http_sl($chan,$data,$uuid)
  401. {
  402. $xmldata = "<?xml version=\"1.0\"?><methodCall><methodName>llRemoteData</methodName>
  403. <params><param><value><struct>
  404. <member><name>Channel</name><value><string>".$uuid."</string></value></member>
  405. <member><name>IntValue</name><value><int>".$chan."</int></value></member>
  406. <member><name>StringValue</name><value><string>".$data."</string></value></member>
  407. </struct></value></param></params></methodCall>";
  408. sendToHost("xmlrpc.secondlife.com", "POST", "/cgi-bin/xmlrpc.cgi", $xmldata);
  409. }
  410. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement