PageRenderTime 39ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/modules/intranet_email/intra-email-delete.php

https://github.com/timschofield/2.8
PHP | 112 lines | 88 code | 9 blank | 15 comment | 23 complexity | ea8a111a321eb505e654ad3287e38881 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause, GPL-2.0
  1. <?php
  2. error_reporting(E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR);
  3. require('./roots.php');
  4. require('../../include/helpers/inc_environment_global.php');
  5. /**
  6. * CARE2X Integrated Hospital Information System Deployment 2.1 - 2004-10-02
  7. * GNU General Public License
  8. * Copyright 2002,2003,2004,2005 Elpidio Latorilla
  9. * elpidio@care2x.org,
  10. *
  11. * See the file "copy_notice.txt" for the licence notice
  12. */
  13. define('MODULE','intranet_email');
  14. define('LANG_FILE_MODULAR','intranet_email.php');
  15. $local_user='ck_intra_email_user';
  16. require_once($root_path.'include/helpers/inc_front_chain_lang.php');
  17. if(!isset($maxrow)||(isset($maxrow)&&empty($maxrow))||!isset($folder)||(isset($folder)&&empty($folder))) { header("location:intra-email.php".URL_REDIRECT_APPEN."&mode=listmail"); exit;}
  18. if(isset($create)&&$create) {
  19. $del0="t=$t&r=$r&f=$f&s=$s&d=$d&z=$z";
  20. } else {
  21. for($i=0;$i<$maxrow;$i++) {
  22. $delbuf="del$i";
  23. if(isset($$delbuf)&&$$delbuf){ $delok=1; break;}
  24. }
  25. if(!isset($delok)||!$delok) {
  26. header("location:intra-email.php".URL_REDIRECT_APPEND."&mode=listmail"); exit;}
  27. }
  28. //$db->debug=1;
  29. $thisfile=basename(__FILE__);
  30. //foreach($arg as $v) echo "$v<br>"; //init db parameters
  31. $dbtable='care_mail_private_users';
  32. $linecount=0;
  33. $modetypes=array('sendmail','listmail');
  34. $sql="SELECT $folder, lastcheck FROM $dbtable WHERE email='".$_COOKIE[$local_user.$sid]."'";
  35. if($ergebnis=$db->Execute($sql))
  36. {
  37. if($ergebnis->RecordCount())
  38. {
  39. $result=$ergebnis->FetchRow();
  40. $inb=explode("_",trim($result[$folder]));
  41. for($i=0;$i<sizeof($inb);$i++)
  42. {
  43. for($n=0;$n<$maxrow;$n++)
  44. {
  45. $delbuf="del$n";
  46. if(!isset($$delbuf)||!$$delbuf) continue;
  47. $delbuf2=trim(strtr($$delbuf,"+"," "));
  48. //echo "$delbuf2<br>$inb[$i]<br>";
  49. if(stristr($delbuf2,trim($inb[$i])))
  50. {
  51. $trash=array_splice($inb,$i,1);
  52. $i--;
  53. break;
  54. }
  55. }
  56. }
  57. $result[$folder]=implode("_",$inb);
  58. $sql="UPDATE $dbtable SET $folder='".$result[$folder]."', lastcheck='".$result['lastcheck']."'
  59. WHERE email='".$_COOKIE[$local_user.$sid]."'";
  60. $db->BeginTrans();
  61. $ok=$db->Execute($sql);
  62. if($ok&&$db->CommitTrans()) {
  63. // update the recyle folder
  64. if($folder!='trash')
  65. {
  66. $sql="SELECT trash, lastcheck FROM $dbtable WHERE email='".$_COOKIE[$local_user.$sid]."'";
  67. if($ergebnis=$db->Execute($sql))
  68. {
  69. if($ergebnis->RecordCount())
  70. {
  71. $result=$ergebnis->FetchRow();
  72. //echo "$maxrow ";
  73. for($n=0;$n<$maxrow;$n++)
  74. {
  75. $delbuf="del$n";
  76. if(!isset($$delbuf)||!$$delbuf) continue;
  77. $delbuf2=trim(strtr($$delbuf,"+"," "));
  78. //echo $delbuf2."<br>";
  79. if($result['trash']=="") $result['trash']=$delbuf2."\r\n";
  80. else $result['trash'].="_".$delbuf2."\r\n";
  81. }
  82. $sql="UPDATE $dbtable SET trash='".$result['trash']."', lastcheck='".$result['lastcheck']."'
  83. WHERE email='".$_COOKIE[$local_user.$sid]."'";
  84. $db->BeginTrans();
  85. $ok=$db->Execute($sql);
  86. if($ok) {
  87. $db->CommitTrans();
  88. } else {
  89. $db->RollbackTrans();
  90. echo "$LDDbNoUpdate<br>$sql";
  91. }
  92. }
  93. //echo $sql;
  94. } else { echo "$LDDbNoRead<br>$sql"; }
  95. }
  96. header("location:intra-email.php?sid=$sid&lang=$lang&mode=listmail&l2h=$l2h&folder=$folder");
  97. }else {
  98. $db->RollbackTrans();
  99. echo "$LDDbNoUpdate<br>$sql";
  100. }
  101. }
  102. }else { echo "$LDDbNoRead<br>$sql"; }
  103. ?>