Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. <?php
  2. date_default_timezone_set("America/Sao_Paulo");
  3. //define("SERVER", "LOCAL");
  4. define("SERVER", "WEB");
  5. function configurations() {
  6. if(SERVER == "LOCAL") {
  7. error_reporting(1);
  8. ini_set('display_errors', true);
  9. define("URL", "http://".$_SERVER['HTTP_HOST']."/GRANAFACIL/BLOG");
  10. } else {
  11. error_reporting(0);
  12. ini_set('display_errors', false);
  13. define("URL", "http://".$_SERVER['HTTP_HOST']."");
  14. }
  15. }
  16.  
  17. function decoder($hex){
  18. $string='';
  19. for ($i=0; $i < strlen($hex)-1; $i+=2){
  20. $string .= chr(hexdec($hex[$i].$hex[$i+1]));
  21. }
  22. return $string;
  23. }
  24.  
  25. function urlAtual(){
  26. $dominio= $_SERVER['HTTP_HOST'];
  27. $url = "http://" . $dominio. $_SERVER['REQUEST_URI'];
  28. return $url;
  29. }
  30.  
  31. function limitar($text, $qntd) {
  32. return substr_replace($text, (strlen($text) > $qntd ? '...' : ''), $qntd);
  33. }
  34.  
  35. function countryGet($ip_address) {
  36. require "dbip.class.php";
  37. try {
  38. $db = new PDO("mysql:host=mysql.granasocial.com.br;dbname=granasocial", "granasocial", "123Bo456");
  39. $dbip = new DBIP($db);
  40. $inf = $dbip->Lookup($ip_address);
  41. return $inf->country;
  42.  
  43. } catch (DBIP_Exception $e) {
  44.  
  45. }
  46. }
  47.  
  48. configurations();
  49. function openConnection() {
  50. global $mysqli;
  51. $host = (SERVER == "LOCAL") ? "localhost" : "mysql.granasocial.com.br";
  52. $user = (SERVER == "LOCAL") ? "root" : "granasocial";
  53. $pass = (SERVER == "LOCAL") ? "" : "123Bo456";
  54. $data = (SERVER == "LOCAL") ? "granafacil" : "granasocial";
  55. $mysqli = new mysqli($host, $user, $pass, $data);
  56. if ($mysqli->connect_error) {}
  57. }
  58. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement