Advertisement
Guest User

Cristiano

a guest
Jul 21st, 2018
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.62 KB | None | 0 0
  1. <?php
  2.  
  3. // error_reporting(E_ALL ^ E_NOTICE);
  4.  
  5. if ( (!defined('BASE_INCLUSA')) or (count(get_included_files()) == 1) )
  6. {
  7. header( $_SERVER["SERVER_PROTOCOL"]." 404 Not Found", true, 404 );
  8. exit();
  9. }
  10.  
  11. ####
  12. ####
  13. ####
  14.  
  15. define( 'USR_INCLUSO', true );
  16. require_once( dirname( $_SERVER["DOCUMENT_ROOT"] ) . "/usr.php" );
  17.  
  18. // $app["raiz"] = dirname(__FILE__);
  19.  
  20. define( "APP_RAIZ", dirname(__FILE__) . "/dashboard/" );
  21. // define( "APP", "RAIZ" => dirname(__FILE__) );
  22.  
  23. ####
  24. ####
  25. ####
  26.  
  27. // $db["sys_pct"]["pk"] = "paciente_id";
  28.  
  29. define( "THE_ROOT", $_SERVER["DOCUMENT_ROOT"] . "/" );
  30.  
  31. define( "THE_ROOT_DEBUG", THE_ROOT . "debug" );
  32. define( "THE_ROOT_SESSOES", THE_ROOT . "sessoes" );
  33. // define( "THE_ROOT_API", THE_ROOT . "api" );
  34. define( "THE_ROOT_CLASS", THE_ROOT . "classes" );
  35. // define( "THE_ROOT_SMTP", THE_ROOT_API . "/smtp" );
  36. // define( "THE_ROOT_INCLUDE", THE_ROOT . "inc" );
  37.  
  38. define( "THE_ROOT_CABECALHO", THE_ROOT . "header.php" );
  39. define( "THE_ROOT_RODAPE", THE_ROOT . "footer.php" );
  40.  
  41. define( "THE_ROOT_ESTATICOS", THE_ROOT . "estaticos" );
  42.  
  43. /*
  44.  
  45. define( "THE_ROOT_CARIMBOS", THE_ROOT_ESTATICOS . "/carimbos" );
  46. define( "THE_ROOT_CARIMBOS_FISIO", THE_ROOT_CARIMBOS . "/fisio" );
  47. define( "THE_ROOT_CARIMBOS_FONO", THE_ROOT_CARIMBOS . "/fono" );
  48. define( "THE_ROOT_CARIMBOS_TO", THE_ROOT_CARIMBOS . "/to" );
  49. define( "THE_ROOT_CARIMBOS_NUTR", THE_ROOT_CARIMBOS . "/nutri" );
  50.  
  51. define( "THE_ROOT_CURRICULOS", THE_ROOT_ESTATICOS . "/curriculos" );
  52. */
  53.  
  54. define( "THE_ROOT_IMAGENS", THE_ROOT_ESTATICOS . "/imagens" );
  55.  
  56. ####
  57. ####
  58. ####
  59.  
  60. /*
  61.  
  62. define( "THE_VOLUME", "/mnt/volume-nyc1-01/fisiolar" );
  63.  
  64. #
  65.  
  66. define( "VOLUME_CURRICULOS", THE_VOLUME."/curriculos" );
  67.  
  68. define( "VOLUME_CARIMBOS", THE_VOLUME."/carimbos" );
  69. define( "VOLUME_CARIMBOS_FTA", VOLUME_CARIMBOS."/fta" );
  70. define( "VOLUME_CARIMBOS_FGA", VOLUME_CARIMBOS."/fga" );
  71. define( "VOLUME_CARIMBOS_TO", VOLUME_CARIMBOS."/to" );
  72. define( "VOLUME_CARIMBOS_NUTR", VOLUME_CARIMBOS."/nutr" );
  73.  
  74. define( "VOLUME_FICHAS", THE_VOLUME."/fichas" );
  75. define( "VOLUME_FICHAS_FTA", VOLUME_FICHAS."/fta" );
  76. define( "VOLUME_FICHAS_FGA", VOLUME_FICHAS."/fga" );
  77. define( "VOLUME_FICHAS_TO", VOLUME_FICHAS."/to" );
  78. define( "VOLUME_FICHAS_NUTR", VOLUME_FICHAS."/nutr" );
  79.  
  80. #
  81.  
  82. define( "THE_ROOT_CURRICULOS", THE_VOLUME."/curriculos" );
  83.  
  84. define( "THE_ROOT_CARIMBOS", THE_VOLUME."/carimbos" );
  85. define( "THE_ROOT_CARIMBOS_FISIO", THE_ROOT_CARIMBOS."/fta" );
  86. define( "THE_ROOT_CARIMBOS_FONO", THE_ROOT_CARIMBOS."/fga" );
  87. define( "THE_ROOT_CARIMBOS_TO", THE_ROOT_CARIMBOS."/to" );
  88. define( "THE_ROOT_CARIMBOS_NUTR", THE_ROOT_CARIMBOS."/nutr" );
  89.  
  90. // define( "THE_ROOT_FICHAS", THE_VOLUME . "/fichas" );
  91.  
  92. define( "THE_ROOT_FICHAS", THE_ROOT_ESTATICOS . "/fichas" );
  93. define( "THE_ROOT_FICHAS_FISIO", THE_ROOT_FICHAS . "/fisio" );
  94. define( "THE_ROOT_FICHAS_FONO", THE_ROOT_FICHAS . "/fono" );
  95. define( "THE_ROOT_FICHAS_TO", THE_ROOT_FICHAS . "/to_a" );
  96.  
  97. define( "THE_ROOT_FICHAS_V", THE_VOLUME . "/fichas" );
  98. define( "THE_ROOT_FICHAS_FISIO_V", THE_ROOT_FICHAS_V . "/fta" );
  99. define( "THE_ROOT_FICHAS_FONO_V", THE_ROOT_FICHAS_V . "/fga" );
  100. define( "THE_ROOT_FICHAS_TO_V", THE_ROOT_FICHAS_V . "/to" );
  101.  
  102. // define( "THE_ROOT_FICHAS_NUTR", THE_ROOT_FICHAS . "/nutr" );
  103.  
  104. // define( "THE_ROOT_FICHAS_FISIO", THE_ROOT_FICHAS . "/fisio" );
  105. // define( "THE_ROOT_FICHAS_FONO", THE_ROOT_FICHAS . "/fono" );
  106. // define( "THE_ROOT_FICHAS_NUTR", THE_ROOT_FICHAS . "/nutri" );
  107. // define( "THE_ROOT_FICHAS_TO", THE_ROOT_FICHAS . "/to" );
  108.  
  109. // define( "THE_ROOT_FICHAS", THE_VOLUME . "/fichas" );
  110. // define( "THE_ROOT_FICHAS_FISIO", THE_ROOT_FICHAS . "/fta" );
  111. // define( "THE_ROOT_FICHAS_FONO", THE_ROOT_FICHAS . "/fga" );
  112. // define( "THE_ROOT_FICHAS_TO", THE_ROOT_FICHAS . "/to" );
  113. // define( "THE_ROOT_FICHAS_NUTR", THE_ROOT_FICHAS . "/nutr" );
  114.  
  115. */
  116.  
  117. ####
  118. ####
  119. ####
  120.  
  121. if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
  122. {
  123. $protocol = 'https';
  124. }
  125. else
  126. {
  127. $protocol = 'http';
  128. }
  129.  
  130. define( "WEB_PROTOCOL", "{$protocol}://" );
  131. define( "WEB_ROOT", WEB_PROTOCOL . $_SERVER["SERVER_NAME"] . "/" );
  132.  
  133. define( "WEB_ROOT_DASHBOARD", WEB_ROOT . "dashboard/" );
  134.  
  135. define( "ROOT_DASHBOARD", WEB_ROOT . "dashboard/" );
  136.  
  137. // define( "WEB_ROOT_API", WEB_ROOT . "api" );
  138. // define( "WEB_ROOT_ESTATICOS", WEB_ROOT . "estaticos" );
  139.  
  140. // define( "WEB_ROOT_CARIMBOS", WEB_ROOT_ESTATICOS . "/carimbos" );
  141. // define( "WEB_ROOT_CARIMBOS_FISIO", WEB_ROOT_CARIMBOS . "/fisio" );
  142.  
  143. ####
  144. ####
  145. ####
  146.  
  147. # indiano estrutura de config
  148.  
  149. DEFINE("DOMINGO", 0);
  150. DEFINE("SEGUNDA", 1);
  151. DEFINE("TERCA", 2);
  152. DEFINE("QUARTA", 3);
  153. DEFINE("QUINTA", 4);
  154. DEFINE("SEXTA", 5);
  155. DEFINE("SABADO", 6);
  156.  
  157. $gl_nome_dia[DOMINGO] = "Domingo";
  158. $gl_nome_dia[SEGUNDA] = "Segunda-feira";
  159. $gl_nome_dia[TERCA] = "Terça-feira";
  160. $gl_nome_dia[QUARTA] = "Quarta-feira";
  161. $gl_nome_dia[QUINTA] = "Quinta-feira";
  162. $gl_nome_dia[SEXTA] = "Sexta-feira";
  163. $gl_nome_dia[SABADO] = "Sábado";
  164.  
  165. $gl_mes[1] = "Janeiro";
  166. $gl_mes[2] = "Fevereiro";
  167. $gl_mes[3] = "Março";
  168. $gl_mes[4] = "Abril";
  169. $gl_mes[5] = "Maio";
  170. $gl_mes[6] = "Junho";
  171. $gl_mes[7] = "Julho";
  172. $gl_mes[8] = "Agosto";
  173. $gl_mes[9] = "Setembro";
  174. $gl_mes[10] = "Outubro";
  175. $gl_mes[11] = "Novembro";
  176. $gl_mes[12] = "Dezembro";
  177.  
  178. $ab_mes[1] = "jan";
  179. $ab_mes[2] = "fev";
  180. $ab_mes[3] = "mar";
  181. $ab_mes[4] = "abr";
  182. $ab_mes[5] = "mai";
  183. $ab_mes[6] = "jun";
  184. $ab_mes[7] = "jul";
  185. $ab_mes[8] = "ago";
  186. $ab_mes[9] = "set";
  187. $ab_mes[10] = "out";
  188. $ab_mes[11] = "nov";
  189. $ab_mes[12] = "dez";
  190.  
  191. $gl_estados["AC"] = "Acre";
  192. $gl_estados["AL"] = "Alagoas";
  193. $gl_estados["AM"] = "Amazonas";
  194. $gl_estados["AP"] = "Amapá";
  195. $gl_estados["BA"] = "Bahia";
  196. $gl_estados["CE"] = "Ceará";
  197. $gl_estados["DF"] = "Distrito Federal";
  198. $gl_estados["ES"] = "Espirito Santo";
  199. $gl_estados["GO"] = "Goiás";
  200. $gl_estados["MA"] = "Maranhão";
  201. $gl_estados["MT"] = "Mato Grosso";
  202. $gl_estados["MS"] = "Mato Grosso do Sul";
  203. $gl_estados["MG"] = "Minas Gerais";
  204. $gl_estados["PA"] = "Pará";
  205. $gl_estados["PB"] = "Paraíba";
  206. $gl_estados["PR"] = "Paraná";
  207. $gl_estados["PE"] = "Pernambuco";
  208. $gl_estados["PI"] = "Piauí";
  209. $gl_estados["RJ"] = "Rio de Janeiro";
  210. $gl_estados["RN"] = "Rio Grande do Norte";
  211. $gl_estados["RO"] = "Rondônia";
  212. $gl_estados["RS"] = "Rio Grande do Sul";
  213. $gl_estados["RR"] = "Roraima";
  214. $gl_estados["SC"] = "Santa Catarina";
  215. $gl_estados["SE"] = "Sergipe";
  216. $gl_estados["SP"] = "São Paulo";
  217. $gl_estados["TO"] = "Tocantins";
  218.  
  219. $gl_condicao["0"] = "Ativo";
  220. $gl_condicao["1"] = "Óbito";
  221. $gl_condicao["2"] = "Alta";
  222.  
  223. $str_yn["0"] = "Não";
  224. $str_yn["1"] = "Sim";
  225.  
  226. $str_upload_errors[UPLOAD_ERR_OK] = 'Não houve erro, o envio foi bem sucedido';
  227. $str_upload_errors[UPLOAD_ERR_INI_SIZE] = 'O tamanho do arquivo excede o limite definido no servidor';
  228. $str_upload_errors[UPLOAD_ERR_FORM_SIZE] = 'O tamanho do arquivo excede o limite definido no formulário de envio';
  229. $str_upload_errors[UPLOAD_ERR_PARTIAL] = 'O envio do arquivo foi feito parcialmente';
  230. $str_upload_errors[UPLOAD_ERR_NO_FILE] = 'Nenhum arquivo foi enviado';
  231. $str_upload_errors[UPLOAD_ERR_NO_TMP_DIR] = 'Pasta temporária ausênte';
  232. $str_upload_errors[UPLOAD_ERR_CANT_WRITE] = 'Falha em escrever o arquivo no servidor';
  233. $str_upload_errors[UPLOAD_ERR_EXTENSION] = 'Uma extensão do PHP interrompeu o upload do arquivo';
  234.  
  235. ####
  236. ####
  237. ####
  238.  
  239. define( "NIVEL_USUARIO", 0 );
  240. define( "NIVEL_ADMINISTRATIVO", 1 );
  241.  
  242. ####
  243. ####
  244. ####
  245.  
  246. /*
  247. define( "NOME_BUCKET", "fisiolar-sistema" );
  248.  
  249. define("THE_AMAZON_CARIMBOS_FISIO", "https://s3-sa-east-1.amazonaws.com/".NOME_BUCKET."/carimbos/fisio/");
  250. define("THE_AMAZON_CARIMBOS_FONO", "https://s3-sa-east-1.amazonaws.com/".NOME_BUCKET."/carimbos/fono/");
  251. define("THE_AMAZON_CARIMBOS_TO", "https://s3-sa-east-1.amazonaws.com/".NOME_BUCKET."/carimbos/to/");
  252. define("THE_AMAZON_CARIMBOS_NUTR", "https://s3-sa-east-1.amazonaws.com/".NOME_BUCKET."/carimbos/nutri/");
  253.  
  254. define("THE_AMAZON_FICHAS_FISIO", "https://s3-sa-east-1.amazonaws.com/".NOME_BUCKET."/fichas/fisio/");
  255. define("THE_AMAZON_FICHAS_FONO", "https://s3-sa-east-1.amazonaws.com/".NOME_BUCKET."/fichas/fono/");
  256. define("THE_AMAZON_FICHAS_TO", "https://s3-sa-east-1.amazonaws.com/".NOME_BUCKET."/fichas/to/");
  257. define("THE_AMAZON_FICHAS_NUTR", "https://s3-sa-east-1.amazonaws.com/".NOME_BUCKET."/fichas/nutri/");
  258.  
  259. // define("THE_AMAZON_FICHAS_OLD", "https://s3-sa-east-1.amazonaws.com/".NOME_BUCKET."/fichas/antigo/");
  260.  
  261. define("THE_AMAZON_CURRICULOS", "https://s3-sa-east-1.amazonaws.com/".NOME_BUCKET."/curriculos/");
  262.  
  263. ####
  264. ####
  265. ####
  266.  
  267. define( "MAX_FOLHAS_GEAP", 4 );
  268.  
  269. define( "TAMANHO_MAXIMO_CURRICULO", 5242880 );
  270. define( "TAMANHO_MAXIMO_CURRICULO_STR", "5 MB" );
  271.  
  272. define( "TAMANHO_MAXIMO_FICHA", 5242880 );
  273. define( "TAMANHO_MAXIMO_FICHA_STR", "5 MB" );
  274.  
  275. define( "TAMANHO_MAXIMO_CARIMBO", 2097152 );
  276. define( "TAMANHO_MAXIMO_CARIMBO_STR", "2 MB" );
  277. */
  278.  
  279. ####
  280. ####
  281. ####
  282.  
  283. define( "SESSAO_TITULO", "log" );
  284.  
  285. define( "sSessaoLogado", "logado" );
  286. define( "sSessaoPessoa", "pessoa_id" );
  287. // define( "sSessaoFisio", "fisio_id" );
  288. // define( "sSessaoFono", "fono_id" );
  289. // define( "sSessaoNutr", "nutr_id" );
  290. // define( "sSessaoTo", "to_id" );
  291. define( "sSessaoPrivilegio", "pessoa_privilegio" );
  292. define( "sUsuario", "pessoa_acesso_usuario" );
  293. define( "sNome", "pessoa_nome" );
  294. define( "sSessaoTempoInicial", "tempo_inicio" );
  295. define( "sSessaoTempo", "tempo_real" );
  296. define( "sSessaoIP", "ip" );
  297. define( "sSessaoURL", "url" );
  298. define( "sSessaoAGENTE", "agente" );
  299.  
  300. ini_set( "session.save_path", THE_ROOT_SESSOES );
  301. ini_set( "session.use_cookies", 1 );
  302. ini_set( "session.use_only_cookies", 1 );
  303. ini_set( "session.cookie_secure", 1 );
  304. ini_set( "session.cookie_httponly", 1 );
  305. ini_set( "session.cookie_lifetime", 0 );
  306. ini_set( "session.use_strict_mode", 1 );
  307. ini_set( "session.use_trans_sid", 0 );
  308.  
  309. session_start();
  310.  
  311. // ---- RETORNA ID DA LINHA CORRESPONDENTE NA TABELA MYSQL
  312.  
  313. function getPessoaID() {
  314. return (int)$_SESSION[SESSAO_TITULO][sSessaoPessoa];
  315. }
  316.  
  317. /*
  318. function getFisioID() {
  319. return (int)$_SESSION[SESSAO_TITULO][sSessaoFisio];
  320. }
  321.  
  322. function getFonoID() {
  323. return (int)$_SESSION[SESSAO_TITULO][sSessaoFono];
  324. }
  325.  
  326. function getTerapeutaOcupacionalID() {
  327. return (int)$_SESSION[SESSAO_TITULO][sSessaoTo];
  328. }
  329.  
  330. function getNutrID() {
  331. return (int)$_SESSION[SESSAO_TITULO][sSessaoNutr];
  332. }
  333.  
  334. // ---- VALIDAÇÃO DE PREVILÉGIOS
  335.  
  336. function IsFISIO()
  337. {
  338. return ( getFisioID() !== -1 );
  339. }
  340.  
  341. function IsFONO()
  342. {
  343. return ( getFonoID() !== -1 );
  344. }
  345.  
  346. function IsTerapeutaOcupacional()
  347. {
  348. return ( getTerapeutaOcupacionalID() !== -1 );
  349. }
  350.  
  351. function IsNutricionista()
  352. {
  353. return ( getNutrID() !== -1 );
  354. }
  355. */
  356.  
  357. function fmtNivel($nivel)
  358. {
  359. $nome = "Desconhecido";
  360. if ( (int)$nivel === NIVEL_USUARIO ) {
  361. $nome = "Usuário";
  362. } else if ( (int)$nivel === NIVEL_ADMINISTRATIVO ) {
  363. $nome = "Administração";
  364. }
  365. return $nome;
  366. }
  367.  
  368. function lerNivel()
  369. {
  370. return (int)$_SESSION[SESSAO_TITULO][sSessaoPrivilegio];
  371. }
  372.  
  373. /*
  374. function IsOnlyADMIN()
  375. {
  376. return ( (lerNivel() >= NIVEL_OPERACIONAL) and (!IsFISIO()) and (!IsFONO()) and (!IsTerapeutaOcupacional()) and (!IsNutricionista()) );
  377. }
  378.  
  379. function IsNADA()
  380. {
  381. return ( (lerNivel() === NIVEL_USUARIO) and (!IsFISIO()) and (!IsFONO()) and (!IsTerapeutaOcupacional()) and (!IsNutricionista()) );
  382. }
  383. */
  384.  
  385. function EstaLogado()
  386. {
  387. return ( (string)$_SESSION[SESSAO_TITULO][sSessaoLogado] === "1" );
  388. }
  389.  
  390. // function SaidaSessao()
  391. // {
  392. // return var_export($_SESSION, true);
  393. // }
  394.  
  395. function sessaoID()
  396. {
  397. return session_id();
  398. }
  399.  
  400. ####
  401. ####
  402. ####
  403.  
  404. #
  405.  
  406. ####
  407. ####
  408. ####
  409.  
  410. $isMobile = (
  411. preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i', $_SERVER['HTTP_USER_AGENT'])
  412. ||
  413. preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i', substr($_SERVER['HTTP_USER_AGENT'], 0, 4))
  414. );
  415.  
  416. ####
  417. ####
  418. ####
  419.  
  420. function weeks_in_month( $year, $month, $start_day_of_week )
  421. {
  422. // Total number of days in the given month.
  423. $num_of_days = date( "t", mktime( 0, 0, 0, $month, 1, $year ) );
  424.  
  425. // Count the number of times it hits $start_day_of_week.
  426. $num_of_weeks = 0;
  427.  
  428. for ( $i = 1; $i <= $num_of_days; $i++ )
  429. {
  430. $day_of_week = date( 'w', mktime( 0, 0, 0, $month, $i, $year ) );
  431.  
  432. if ( $day_of_week == $start_day_of_week ) {
  433. $num_of_weeks++;
  434. }
  435. }
  436.  
  437. return $num_of_weeks;
  438. }
  439.  
  440. function QualIP()
  441. {
  442. if ( !empty($_SERVER['HTTP_CLIENT_IP']) ) {
  443. $ip = $_SERVER['HTTP_CLIENT_IP'];
  444. } elseif ( !empty($_SERVER['HTTP_X_FORWARDED_FOR']) ) {
  445. $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
  446. } else{
  447. $ip = $_SERVER['REMOTE_ADDR'];
  448. }
  449. return $ip;
  450. }
  451.  
  452. /*
  453.  
  454. $ipAddress = $_SERVER['REMOTE_ADDR'];
  455. if ( array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER) )
  456. {
  457. $ipAddress = array_pop( explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']) );
  458. }
  459.  
  460. */
  461.  
  462. function GerarLOG($prefixo, $origem, $msg)
  463. {
  464. $hAtual = new DateTime();
  465. $err_data = $hAtual->format("d/m/Y");
  466. $err_hora = $hAtual->format("H:i:s");
  467.  
  468. $err_ip = QualIP();
  469.  
  470. $saida = array( "DATA" => $err_data,
  471. "HORA" => $err_hora,
  472. "IP" => $err_ip,
  473. "ORIGEM" => $origem,
  474. "MENSAGEM" => $msg );
  475. $str_saida = ( var_export($saida, true) . PHP_EOL );
  476.  
  477. @file_put_contents( THE_ROOT_DEBUG."/debug_{$prefixo}.log", $str_saida, FILE_APPEND );
  478. }
  479.  
  480. function ErroPDO($origem, $msg)
  481. {
  482. $hAtual = new DateTime();
  483. $err_data = $hAtual->format("d/m/Y");
  484. $err_hora = $hAtual->format("H:i:s");
  485.  
  486. $err_ip = QualIP();
  487.  
  488. $saida = array( "DATA" => $err_data,
  489. "HORA" => $err_hora,
  490. "IP" => $err_ip,
  491. "ORIGEM" => $origem,
  492. "MENSAGEM" => $msg );
  493. $str_saida = ( var_export($saida, true) . PHP_EOL );
  494.  
  495. @file_put_contents( THE_ROOT_DEBUG."/debug_pdo.log", $str_saida, FILE_APPEND );
  496. }
  497.  
  498. function RegistrarEvento( $h_pdo, $codigo, $saida, $v_post, $v_get, $v_file )
  499. {
  500. try
  501. {
  502. $qry_evento = $h_pdo->prepare("INSERT INTO sys_eventos (data,pessoa_id,codigo,evento_post,evento_get,evento_file,saida,zip) VALUES (NOW(),:pessoa,:codigo,COMPRESS(:post),COMPRESS(:get),COMPRESS(:file),:saida,1)");
  503. $qry_evento->bindValue( ":pessoa", getPessoaID() );
  504. $qry_evento->bindValue( ":codigo", $codigo );
  505. if (trim($v_post) != "") {
  506. $qry_evento->bindValue( ":post", "{$v_post}" );
  507. } else {
  508. $qry_evento->bindValue( ":post", null );
  509. }
  510. if (trim($v_get) != "") {
  511. $qry_evento->bindValue( ":get", "{$v_get}" );
  512. } else {
  513. $qry_evento->bindValue( ":get", null );
  514. }
  515. if (trim($v_file) != "") {
  516. $qry_evento->bindValue( ":file", "{$v_file}" );
  517. } else {
  518. $qry_evento->bindValue( ":file", null );
  519. }
  520. $qry_evento->bindValue( ":saida", $saida );
  521. $qry_evento->execute();
  522. $qry_evento = null;
  523. }
  524. catch(PDOException $pdo_err)
  525. {
  526. $pdo_error = true;
  527. ErroPDO( $_SERVER["PHP_SELF"], $pdo_err->getMessage() );
  528. }
  529. }
  530.  
  531. function RegistrarNavegacao( $h_pdo, $script, $url )
  532. {
  533. try
  534. {
  535. $qry_evento = $h_pdo->prepare("INSERT INTO sys_navegacao (pessoa_id,data,ip,user_agent,script,url) VALUES (:pessoa,NOW(),:ip,:agente,:script,:url)");
  536. $qry_evento->bindValue( ":pessoa", getPessoaID() );
  537. $qry_evento->bindValue( ":ip", QualIP() );
  538. $qry_evento->bindValue( ":agente", $_SERVER["HTTP_USER_AGENT"] );
  539. $qry_evento->bindValue( ":script", $script );
  540. $qry_evento->bindValue( ":url", $url );
  541. $qry_evento->execute();
  542. $qry_evento = null;
  543. }
  544. catch(PDOException $pdo_err)
  545. {
  546. $pdo_error = true;
  547. ErroPDO( $_SERVER["PHP_SELF"], $pdo_err->getMessage() );
  548. }
  549. }
  550.  
  551. ####
  552. ####
  553. ####
  554.  
  555. // Convert an UTF-8 encoded string to a single-byte string suitable for
  556. // functions such as levenshtein.
  557. //
  558. // The function simply uses (and updates) a tailored dynamic encoding
  559. // (in/out map parameter) where non-ascii characters are remapped to
  560. // the range [128-255] in order of appearance.
  561. //
  562. // Thus it supports up to 128 different multibyte code points max over
  563. // the whole set of strings sharing this encoding.
  564. //
  565. function utf8_to_extended_ascii($str, &$map)
  566. {
  567. // find all multibyte characters (cf. utf-8 encoding specs)
  568. $matches = array();
  569. if (!preg_match_all('/[\xC0-\xF7][\x80-\xBF]+/', $str, $matches))
  570. return $str; // plain ascii string
  571.  
  572. // update the encoding map with the characters not already met
  573. foreach ($matches[0] as $mbc)
  574. if (!isset($map[$mbc]))
  575. $map[$mbc] = chr(128 + count($map));
  576.  
  577. // finally remap non-ascii characters
  578. return strtr($str, $map);
  579. }
  580.  
  581. // Didactic example showing the usage of the previous conversion function but,
  582. // for better performance, in a real application with a single input string
  583. // matched against many strings from a database, you will probably want to
  584. // pre-encode the input only once.
  585. //
  586. function levenshtein_utf8($s1, $s2)
  587. {
  588. $charMap = array();
  589. $s1 = utf8_to_extended_ascii($s1, $charMap);
  590. $s2 = utf8_to_extended_ascii($s2, $charMap);
  591.  
  592. return levenshtein($s1, $s2);
  593. }
  594.  
  595. function LimparNome($str, $direcao = MB_CASE_UPPER)
  596. {
  597. setlocale( LC_CTYPE, 'pt_BR.utf8' );
  598. $str = iconv( 'utf-8', 'us-ascii//TRANSLIT', $str );
  599.  
  600. $str = preg_replace( "/[^[:alpha:][:space:]]/u", '', $str );
  601. $str = preg_replace( "!\s+!", " ", $str );
  602. $str = trim( $str );
  603.  
  604. return mb_convert_case( $str, $direcao, "utf-8" );
  605. }
  606.  
  607. function ordernarColuna(&$arr, $col, $dir = SORT_ASC)
  608. {
  609. $sort_col = array();
  610.  
  611. foreach ( $arr as $key => $row )
  612. {
  613. $sort_col[$key] = $row[$col];
  614. }
  615.  
  616. array_multisort($sort_col, $dir, $arr);
  617. }
  618.  
  619. /*
  620. function remoteFileExists( $url )
  621. {
  622. $ch = @curl_init( $url );
  623. @curl_setopt($ch, CURLOPT_NOBODY, true);
  624. @curl_exec($ch);
  625. $retcode = @curl_getinfo($ch, CURLINFO_HTTP_CODE);
  626. @curl_close($ch);
  627.  
  628. return ( $retcode === 200 ); // $retcode >= 400 -> not found, $retcode = 200, found.
  629. }
  630. */
  631.  
  632. function encodeURIComponent($str)
  633. {
  634. $revert = array('%21'=>'!', '%2A'=>'*', '%28'=>'(', '%29'=>')');
  635. return strtr( urlencode($str), $revert );
  636. }
  637.  
  638. function mask($val, $mask)
  639. {
  640. $maskared = '';
  641. $k = 0;
  642. for ( $i = 0; $i <= strlen($mask)-1; $i++ )
  643. {
  644. if ( $mask[$i] == '#' )
  645. {
  646. if ( isset($val[$k]) ) {
  647. $maskared .= $val[$k++];
  648. }
  649. }
  650. else
  651. {
  652. if ( isset($mask[$i]) ) {
  653. $maskared .= $mask[$i];
  654. }
  655. }
  656. }
  657. return $maskared;
  658. }
  659.  
  660. function get_string_between($string, $start, $end)
  661. {
  662. $string = " ".$string;
  663. $ini = strpos($string,$start);
  664. if ($ini == 0) return "";
  665. $ini += strlen($start);
  666. $len = strpos($string,$end,$ini) - $ini;
  667. return substr($string,$ini,$len);
  668. }
  669.  
  670. function calcular_idade($data_nascimento)
  671. {
  672. $stt_nascimento = strtotime($data_nascimento);
  673. if($stt_nascimento == false) {
  674. return false;
  675. }
  676.  
  677. $stt_agora = strtotime("now");
  678.  
  679. list($y1, $m1, $d1) = explode( "-", date("Y-m-d", $stt_nascimento) );
  680. list($y2, $m2, $d2) = explode( "-", date("Y-m-d", $stt_agora) );
  681.  
  682. $stt_nascimento = ($y2 - $y1);
  683.  
  684. if ((int)($m2.$d2) < (int)($m1.$d1)) {
  685. $stt_nascimento -= 1;
  686. }
  687. return $stt_nascimento;
  688. }
  689.  
  690. function fmt_idade($data_nascimento)
  691. {
  692. # $stt_nascimento = ( preg_match("/^(0[1-9]|[12][0-9]|3[01])\/(0[1-9]|1[012])\/(18|19|20)\d\d$/", $data_nascimento) );
  693. $stt_nascimento = ( preg_match("/^((18|19|20)\d\d)-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$/", $data_nascimento) );
  694.  
  695. if (!$stt_nascimento)
  696. {
  697. return ""; # Formato inválido
  698. }
  699. else
  700. {
  701. # $fmt_data = preg_replace("/(\d+)\D+(\d+)\D+(\d+)/", "$3-$2-$1", $data_nascimento);
  702. $fmt_data = $data_nascimento;
  703.  
  704. $date = new DateTime("{$fmt_data}");
  705. $diff = $date->diff( new DateTime("today") );
  706.  
  707. $str_ano = ( ($diff->y == 1) ? "ano" : "anos" );
  708. $str_mes = ( ($diff->m == 1) ? "mês" : "meses" );
  709. $str_dia = ( ($diff->d == 1) ? "dia" : "dias" );
  710.  
  711. $str_anoz = ( ($diff->y >= 1) ? "{$diff->y} {$str_ano}" : "" );
  712. $str_mesz = ( ($diff->m >= 1) ? "{$diff->m} {$str_mes}" : "" );
  713. $str_diaz = ( ($diff->d >= 1) ? "{$diff->d} {$str_dia}" : "" );
  714.  
  715. if (($diff->y == 0) and ($diff->m == 0) and ($diff->d == 0)) {
  716. $retorno = "Hoje";
  717. } else if (($diff->y == 0) and ($diff->m == 0) and ($diff->d > 0)) {
  718. $retorno = "{$diff->d} {$str_dia}";
  719. } else if (($diff->y == 0) and ($diff->m > 0) and ($diff->d == 0)) {
  720. $retorno = "{$diff->m} {$str_mes}";
  721. } else if (($diff->y == 0) and ($diff->m > 0) and ($diff->d > 0)) {
  722. $retorno = "{$diff->m}m {$diff->d}d";
  723. } else if (($diff->y > 0) and ($diff->m == 0)) {
  724. $retorno = "{$diff->y} {$str_ano}";
  725. } else if (($diff->y > 0) and ($diff->m > 0)) {
  726. #$retorno = "{$diff->y}a {$diff->m}m";
  727. $retorno = "{$diff->y} {$str_ano}";
  728. }
  729.  
  730. # return $fmt_data.": ".$retorno;
  731. return $retorno;
  732. }
  733. }
  734.  
  735. function dateIsBetween($date_time_a, $date_time_b, $date_time_teste)
  736. {
  737. $stt_start = strtotime($date_time_a);
  738. $stt_end = strtotime($date_time_b);
  739. $stt_test = strtotime($date_time_teste);
  740. return (($stt_test >= $stt_start) and ($stt_test <= $stt_end));
  741. }
  742.  
  743. function inTimeRange($data, $INICIO, $FINAL, $BUSCA)
  744. {
  745. $res = false;
  746. $t_inicio = strtotime("{$data} {$INICIO}:00");
  747. $t_final = strtotime("{$data} {$FINAL}:00");
  748. $t_busca = strtotime("{$data} {$BUSCA}:00");
  749. if ($t_inicio >= $t_final) $t_final = strtotime('+1 day', $t_final);
  750. return ($t_busca >= $t_inicio) and ($t_busca <= $t_final); // or return ($t_busca > $t_inicio) && ($t_busca < $t_final);
  751. }
  752.  
  753. function datescompare($a, $b)
  754. {
  755. $a = strtotime("01/".$a); //dirty, but works
  756. $b = strtotime("01/".$b);
  757.  
  758. return ($b-$a);
  759. }
  760.  
  761. function formatar_tamanho($bytes, $precision = 2)
  762. {
  763. $units = array('B', 'KB', 'MB', 'GB', 'TB');
  764. $bytes = max($bytes, 0);
  765. $pow = floor(($bytes ? log($bytes) : 0) / log(1024));
  766. $pow = min($pow, count($units) - 1);
  767. // Uncomment one of the following alternatives
  768. $bytes /= pow(1024, $pow);
  769. // $bytes /= (1 << (10 * $pow));
  770. return round($bytes, $precision) . ' ' . $units[$pow];
  771. }
  772.  
  773. function valida_cpf($cpf = false)
  774. {
  775. if (!function_exists('calc_digitos_posicoes'))
  776. {
  777. function calc_digitos_posicoes( $digitos, $posicoes = 10, $soma_digitos = 0 )
  778. {
  779. for ( $i = 0; $i < strlen( $digitos ); $i++ ) {
  780. $soma_digitos = $soma_digitos + ( $digitos[$i] * $posicoes );
  781. $posicoes--;
  782. }
  783. $soma_digitos = $soma_digitos % 11;
  784. if ( $soma_digitos < 2 ) {
  785. $soma_digitos = 0;
  786. } else {
  787. $soma_digitos = 11 - $soma_digitos;
  788. }
  789. $cpf = $digitos . $soma_digitos;
  790. return $cpf;
  791. }
  792. }
  793. if ( ! $cpf ) {
  794. return false;
  795. }
  796. $cpf = preg_replace( '/[^0-9]/is', '', $cpf );
  797. if ( strlen( $cpf ) != 11 ) {
  798. return false;
  799. }
  800. $digitos = substr($cpf, 0, 9);
  801. $novo_cpf = calc_digitos_posicoes( $digitos );
  802. $novo_cpf = calc_digitos_posicoes( $novo_cpf, 11 );
  803. if ( $novo_cpf == $cpf ) {
  804. return true;
  805. } else {
  806. return false;
  807. }
  808. }
  809.  
  810. function aURL()
  811. {
  812. $teste = $_SERVER["SCRIPT_NAME"];
  813. return substr($teste, 1, strrpos($teste, ".php")+4);
  814. }
  815.  
  816. function TresNomes($nome)
  817. {
  818. # ABREVIAR OS DEMAIS...
  819. $saida = trim( preg_replace( "!\s+!", " ", $nome ) ); # agrupa os espaços em um
  820.  
  821. if ( strpos($saida, " ") )
  822. {
  823. $ex_nome = explode(" ", $saida);
  824. $qnt = count($ex_nome);
  825.  
  826. if ($qnt > 2)
  827. {
  828. $opcao = "";
  829. $tok = strtok($saida, " ");
  830.  
  831. while ( $tok = strtok(" ") )
  832. {
  833. if (strlen($tok) > 3)
  834. {
  835. $opcao = $tok;
  836. break;
  837. }
  838. }
  839.  
  840. if ( $opcao != "" )
  841. {
  842. $saida = $ex_nome[0] . " " . $opcao;
  843. if ( $opcao !== end($ex_nome) ) {
  844. $saida = $ex_nome[0] . " " . $opcao . " " . end($ex_nome);
  845. }
  846. }
  847. }
  848. }
  849. return htmlspecialchars( $saida, ENT_QUOTES );
  850. }
  851.  
  852. function searchArrayKeyVal($sKey, $id, $array)
  853. {
  854. foreach ($array as $key => $val)
  855. {
  856. if ($val[$sKey] == $id)
  857. {
  858. return $key;
  859. }
  860. }
  861.  
  862. return false;
  863. }
  864.  
  865. function PrimeiroNome($nome)
  866. {
  867. $nome_profissional = htmlspecialchars( $nome, ENT_QUOTES );
  868. if (strpos($nome_profissional, " ")) {
  869. $nome_profissional = explode(" ", $nome_profissional);
  870. $nome_profissional = $nome_profissional[0]." ".end($nome_profissional);
  871. }
  872. return $nome_profissional;
  873. }
  874.  
  875. function FormatarNome($nome)
  876. {
  877. $saida = htmlspecialchars( trim($nome), ENT_QUOTES );
  878. if (strpos($saida, " ")) {
  879. $tmp = explode(" ", $saida);
  880. $saida = (string)$tmp[0];
  881. }
  882. return $saida;
  883. }
  884.  
  885. function br2nl($contexto)
  886. {
  887. return str_replace("<br />", "\r\n", $contexto);
  888. }
  889.  
  890. ####
  891. ####
  892. ####
  893.  
  894. function checkSessao($close = true)
  895. {
  896. global $_SESSION;
  897.  
  898. $UTC = new DateTimeZone("UTC");
  899. $newTZ = new DateTimeZone("America/Sao_Paulo");
  900. $date = new DateTime( "now", $UTC );
  901. $date->setTimezone( $newTZ );
  902. $tempo_vigente = $date->format("Y-m-d H:i:s");
  903.  
  904. $ip = QualIP();
  905. $url = "{$_SERVER["SERVER_NAME"]}{$_SERVER["REQUEST_URI"]}";
  906.  
  907. // if ( !isset($_SESSION[SESSAO_TITULO][sSessaoTempoInicial]) or ($_SESSION[SESSAO_TITULO][sSessaoTempoInicial] != $tempo_vigente))
  908.  
  909. if ( !isset($_SESSION[SESSAO_TITULO][sSessaoTempoInicial]) )
  910. {
  911. $_SESSION[SESSAO_TITULO][sSessaoTempoInicial] = $tempo_vigente;
  912. }
  913.  
  914. if ( (!isset($_SESSION[SESSAO_TITULO][sSessaoTempo])) or ($_SESSION[SESSAO_TITULO][sSessaoTempo] != $tempo_vigente) )
  915. {
  916. $_SESSION[SESSAO_TITULO][sSessaoTempo] = $tempo_vigente;
  917. }
  918.  
  919. if ( (!isset($_SESSION[SESSAO_TITULO][sSessaoIP])) or ($_SESSION[SESSAO_TITULO][sSessaoIP] != $ip) )
  920. {
  921. $_SESSION[SESSAO_TITULO][sSessaoIP] = $ip;
  922. }
  923.  
  924. if ( (!isset($_SESSION[SESSAO_TITULO][sSessaoURL])) or ($_SESSION[SESSAO_TITULO][sSessaoURL] != $url) )
  925. {
  926. $_SESSION[SESSAO_TITULO][sSessaoURL] = $url;
  927. }
  928.  
  929. if ( (!isset($_SESSION[SESSAO_TITULO][sSessaoAGENTE])) or ($_SESSION[SESSAO_TITULO][sSessaoAGENTE] != $_SERVER["HTTP_USER_AGENT"]) )
  930. {
  931. $_SESSION[SESSAO_TITULO][sSessaoAGENTE] = $_SERVER["HTTP_USER_AGENT"];
  932. }
  933.  
  934. if ( $close )
  935. {
  936. session_write_close();
  937. }
  938. }
  939.  
  940. function sessaoInicio($usuario, $senha, $pessoa_id, $pessoa_privilegio, $pessoa_nome)
  941. {
  942. global $_SESSION;
  943.  
  944. $UTC = new DateTimeZone("UTC");
  945. $newTZ = new DateTimeZone("America/Sao_Paulo");
  946. $date = new DateTime( "now", $UTC );
  947. $date->setTimezone( $newTZ );
  948. $tempo_vigente = $date->format("Y-m-d H:i:s");
  949.  
  950. $_SESSION["persistencia"]["a"] = $usuario;
  951. $_SESSION["persistencia"]["b"] = $senha;
  952.  
  953. $_SESSION[SESSAO_TITULO][sSessaoPessoa] = $pessoa_id;
  954. $_SESSION[SESSAO_TITULO][sSessaoPrivilegio] = $pessoa_privilegio;
  955. $_SESSION[SESSAO_TITULO][sUsuario] = (string)$usuario;
  956. $_SESSION[SESSAO_TITULO][sNome] = $pessoa_nome;
  957. $_SESSION[SESSAO_TITULO]["aviso_index"] = "1";
  958.  
  959. $_SESSION[SESSAO_TITULO][sSessaoLogado] = "1";
  960.  
  961. $i = count($_SESSION[SESSAO_TITULO]["usuarios"])+1;
  962. $_SESSION[SESSAO_TITULO]["usuarios"][$i]["dt"] = $tempo_vigente;
  963. $_SESSION[SESSAO_TITULO]["usuarios"][$i]["id"] = $pessoa_id;
  964.  
  965. // $_SESSION[SESSAO_TITULO]["abas"] = array();
  966.  
  967. session_write_close();
  968. }
  969.  
  970. function sessaoSair()
  971. {
  972. global $_SESSION;
  973.  
  974. // $backup["tempo"] = $_SESSION[SESSAO_TITULO][sSessaoTempoInicial];
  975. // unset( $_SESSION[SESSAO_TITULO] );
  976. // $_SESSION[SESSAO_TITULO][sSessaoTempoInicial] = $backup["tempo"];
  977.  
  978. // unset( $_SESSION[SESSAO_TITULO][sSessaoLogado] );
  979. // unset( $_SESSION[SESSAO_TITULO][sSessaoPessoa] );
  980.  
  981. $_SESSION[SESSAO_TITULO][sSessaoLogado] = "0";
  982.  
  983. session_write_close();
  984. }
  985.  
  986. function sessaoNome($fmt = true)
  987. {
  988. global $_SESSION;
  989.  
  990. $saida = $_SESSION[SESSAO_TITULO][sNome];
  991.  
  992. if ( $fmt )
  993. {
  994. $saida = FormatarNome( $saida );
  995. }
  996.  
  997. return $saida; # htmlentities
  998. }
  999.  
  1000. function sessaoAviso($tmp = null)
  1001. {
  1002. global $_SESSION;
  1003.  
  1004. if ( !is_null($tmp) )
  1005. {
  1006. $_SESSION[SESSAO_TITULO]["aviso_index"] = $tmp;
  1007. session_write_close();
  1008. }
  1009.  
  1010. return $_SESSION[SESSAO_TITULO]["aviso_index"];
  1011. }
  1012.  
  1013. function sessaoPrivilegio($tmp = null)
  1014. {
  1015. global $_SESSION;
  1016.  
  1017. if ( !is_null($tmp) )
  1018. {
  1019. $_SESSION[SESSAO_TITULO][sSessaoPrivilegio] = $tmp;
  1020. session_write_close();
  1021. }
  1022.  
  1023. return $_SESSION[SESSAO_TITULO][sSessaoPrivilegio];
  1024. }
  1025.  
  1026. ####
  1027. ####
  1028. ####
  1029.  
  1030. /*
  1031. $_SESSION = array();
  1032.  
  1033. $useCookies = ini_get("session.use_cookies");
  1034.  
  1035. if ( $useCookies )
  1036. {
  1037. $params = session_get_cookie_params();
  1038. $name = session_name();
  1039. setcookie( $name, "", time() - 42000, $params["path"], $params["domain"], $params["secure"], $params["httponly"] );
  1040. }
  1041.  
  1042. session_destroy();
  1043. */
  1044.  
  1045. // if ( aURL() != "sessoes.php" )
  1046. // if ( (aURL() != "sessoes/sessao.php") and (aURL() != "sessoes.php") )
  1047.  
  1048. if ( (aURL() != "sessao.php") and (aURL() != "sessoes.php") )
  1049. {
  1050. if ( EstaLogado() )
  1051. {
  1052. $_SESSION[SESSAO_TITULO][sSessaoTempo] = (new DateTime("now"))->format("Y-m-d H:i:s");
  1053. }
  1054. }
  1055.  
  1056. ####
  1057. #### CORS
  1058. ####
  1059.  
  1060. header("X-Frame-Options: DENY"); // SAMEORIGIN
  1061. header("X-XSS-Protection: 1; mode=block");
  1062. header("Strict-Transport-Security: max-age=31536000");
  1063. header("X-Content-Type-Options: nosniff");
  1064.  
  1065. // add_header Strict-Transport-Security "max-age=31536000; includeSubdomains; preload";
  1066. // add_header Content-Security-Policy "script-src 'unsafe-inline' 'unsafe-eval' 'self' *.catalogop2p.com.br *.jsdelivr.net *.facebook.com *.facebook.net *.fbcdn.net *.google-analytics.com";
  1067. // add_header Referrer-Policy "no-referrer-when-downgrade";
  1068.  
  1069. // $maxAge = 2592000;
  1070. // header ("Content-Type: application/x-javascript; charset=utf-8");
  1071. // header ("Last-Modified: Thu, 19 Jul 2012 12:56:03 GMT");
  1072. // header ("Expires: " . gmdate ('D, d M Y H:i:s \G\M\T', time () + $maxAge));
  1073. // header ("Cache-Control: max-age=" . $maxAge);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement