functions.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. function pa($debug, $var = false) {
  3. echo "<pre>";
  4. if($var) {
  5. var_dump($debug);
  6. } else {
  7. print_r($debug);
  8. }
  9. echo "</pre>";
  10. }
  11. function curl_download($Url){
  12. // is cURL installed yet?
  13. if (!function_exists('curl_init')){
  14. die('Sorry cURL is not installed!');
  15. }
  16. // OK cool - then let's create a new cURL resource handle
  17. $ch = curl_init();
  18. // Now set some options (most are optional)
  19. // Set URL to download
  20. curl_setopt($ch, CURLOPT_URL, $Url);
  21. // Set a referer
  22. //curl_setopt($ch, CURLOPT_REFERER, "http://www.example.org/yay.htm");
  23. // User agent
  24. curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36");
  25. // Include header in result? (0 = yes, 1 = no)
  26. curl_setopt($ch, CURLOPT_HEADER, 0);
  27. // Should cURL return or print out the data? (true = return, false = print)
  28. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  29. // Timeout in seconds
  30. curl_setopt($ch, CURLOPT_TIMEOUT, 10);
  31. // Download the given URL, and return output
  32. $output = curl_exec($ch);
  33. // Close the cURL resource, and free system resources
  34. curl_close($ch);
  35. return $output;
  36. }
  37. function generatePassword($length = 8) {
  38. $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
  39. $count = mb_strlen($chars);
  40. for ($i = 0, $result = ''; $i < $length; $i++) {
  41. $index = rand(0, $count - 1);
  42. $result .= mb_substr($chars, $index, 1);
  43. }
  44. return $result;
  45. }
  46. ?>