test.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. //no index
  3. header("X-Robots-Tag: noindex, nofollow", true);
  4. //no caché
  5. header('Expires: Sun, 01 Jan 2014 00:00:00 GMT');
  6. header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
  7. header('Cache-Control: no-store, no-cache, must-revalidate');
  8. header('Cache-Control: post-check=0, pre-check=0', false);
  9. header('Pragma: no-cache');
  10. date_default_timezone_set('America/Mexico_City');
  11. //header("Content-Type: text/xml; charset=UTF-8");
  12. require_once("../include/nusoap/nusoap.php");
  13. require_once("../include/bd_pdo.php");
  14. function quitaNumeros($words){
  15. $words = strtoupper($words);
  16. return preg_replace('/\d/', '', $words );
  17. }
  18. function quitaLetras($words){
  19. $words = strtoupper($words);
  20. return preg_replace("/[^0-9]/", "", $words);
  21. }
  22. function getIniciales($materia){
  23. $ret = '';
  24. $materia = str_ireplace( array("Á","É","Í","Ó","Ú","Ñ","Ä","Ë","Ï","Ö","Ü","Â","Ê","Î","Ô","Û","Ã"), array("A","E","I","O","U","N","A","E","I","O","U","A","E","I","O","U","A"), utf8_encode($materia));
  25. foreach (explode(' ', $materia) as $word){
  26. if(ctype_alpha($word[0]))
  27. $ret .= $word[0];
  28. }
  29. return strtoupper($ret);
  30. }
  31. function getareashortname($shortname = "", $pdo){
  32. $tmp = explode('-', $shortname);
  33. $grupo = quitaLetras(str_replace(' ', '', $tmp[0]));
  34. $carrera = quitaNumeros(str_replace(' ', '', $tmp[0]));
  35. $stmt = $pdo->prepare('Select * from fs_areamateria(:gpo, :pref)');
  36. $stmt->bindParam(":gpo", $grupo);
  37. $stmt->bindParam(":pref", $carrera);
  38. if(!$stmt->execute()){
  39. //return "error";
  40. print_r($stmt->errorInfo());
  41. $stmt->closeCursor();
  42. }else{
  43. $materias_rs = $stmt->fetchAll();
  44. $stmt->closeCursor();
  45. foreach($materias_rs as $materia){
  46. if(getIniciales($materia["Materia_desc"]) == strtoupper($tmp[1])){
  47. echo "Area:".$materia["Area_id"];
  48. }
  49. }
  50. }
  51. //return "0";
  52. }
  53. getareashortname("100AB-A-2020A", $pdo);
  54. ?>