index.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. // https://uichi.ortiche.net/index.php/Strutture_dati_di_posta
  3. // version: 0.2
  4. require_once('include/Database.php');
  5. require_once('include/util.php');
  6. require_once('include/localization.php');
  7. require_once('include/template.php');
  8. $err=$user=$email="";
  9. $type="-1";
  10. $rasplice_url="http://rasplice.contaminati.net/cgi-bin/rasplice.txt";
  11. $indivia24hdomain="@24h.indivia.net";
  12. $db=Database::getInstance('std');
  13. function getSqlNumOfAlias($alias_tab,$alias_nic){
  14. $sql = "SELECT count(*)
  15. FROM $alias_tab
  16. WHERE user = '$alias_nic'
  17. AND active = 'Y'";
  18. return $sql;
  19. }
  20. function getSqlCreateAlias($alias_tab, $alias_nic,$alias_dom,$goto_email,$timo){
  21. $sql = "INSERT INTO $alias_tab (user, domain, active, tipo, goto, modified, md5salt, deleted)
  22. VALUES ('$alias_nic', '$alias_dom', 'Y', 'alias', '$goto_email', '$timo','','0')";
  23. return $sql;
  24. }
  25. function getSqlAliasInfo($goto_email){
  26. $sql = "SELECT user
  27. FROM 24h_indivia_net
  28. WHERE goto = '$goto_email'
  29. AND active = 'Y'";
  30. return $sql;
  31. }
  32. //aliasing..
  33. if (isset($_POST["ph"]) AND
  34. $_POST["ph"]=="1" AND
  35. $_POST['email'] != "") {
  36. $goto_email_noescape = $_POST['email'];
  37. $goto_email = $db->escapeString($goto_email_noescape);
  38. if (email_check($goto_email)) {
  39. //solo l'email alias deve non essere presente.
  40. do {
  41. $alias_nic = preg_replace('/\s+/', '', get_data($rasplice_url));
  42. if($alias_nic===FALSE)
  43. $alias_nic="email_".rand(10000,99999);
  44. $alias_dom = substr($indivia24hdomain,1);
  45. $alias_email = $alias_nic.$indivia24hdomain;
  46. $alias_dom2lvl = dom($alias_dom);
  47. $alias_tab = str_replace(".","_",$alias_dom2lvl);
  48. $res = $db->isThereAlready(getSqlNumOfAlias($alias_tab,$alias_nic));
  49. } while ($res != FALSE);
  50. $timo=time();
  51. $ret=$db->execQuery(getSqlCreateAlias($alias_tab,$alias_nic,$alias_dom,$goto_email,$timo));
  52. if ($ret == 1) {
  53. header("location: index.php?ph=2&email=".$goto_email."&lang=".$lang);
  54. } else {
  55. $type=1;
  56. $err=$msgAliasErr;
  57. }
  58. } else {
  59. $type=1;
  60. $err=$msgEmailValidErr;
  61. }
  62. } elseif (isset($_GET["ph"]) AND
  63. $_GET['ph'] == 2 AND
  64. isset($_GET['email'])) {
  65. $goto_email_noescape = $_GET['email'];
  66. $goto_email = $db->escapeString($goto_email_noescape);
  67. $rows = $db->select(getSqlAliasInfo($goto_email));
  68. $row = mysqli_fetch_row($rows);
  69. if ($row[0] != "") {
  70. $type=2;
  71. $user=$row[0];
  72. $email=$goto_email;
  73. } else {
  74. $type=1;
  75. $err=$msgNoEmailFoundErr;
  76. }
  77. } else {
  78. $type=0;
  79. }
  80. if($type>-1) {
  81. printHead($type);
  82. printLangSelector();
  83. printTitle($title);
  84. switch ($type) {
  85. case 0:
  86. printForm($form_goto_email, $lang);
  87. break;
  88. case 1:
  89. printMessage($err);
  90. break;
  91. case 2:
  92. printMessage($msgAliasDonePart1).
  93. printBold($user.$indivia24hdomain).
  94. printMessage($msgAliasDonePart2).
  95. printBold($email);
  96. break;
  97. }
  98. }
  99. ?>