PageRenderTime 42ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/ecm/docother.php

https://github.com/asterix14/dolibarr
PHP | 178 lines | 95 code | 35 blank | 48 comment | 24 complexity | 1fd4c217f8b2bade4d59d29779289066 MD5 | raw file
Possible License(s): LGPL-2.0
  1. <?php
  2. /* Copyright (C) 2008 Laurent Destailleur <eldy@users.sourceforge.net>
  3. */
  4. /**
  5. * \file htdocs/ecm/docother.php
  6. * \ingroup ecm
  7. * \brief Main ecm page
  8. * \author Laurent Destailleur
  9. */
  10. require("../main.inc.php");
  11. require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
  12. require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
  13. // Load traductions files
  14. $langs->load("ecm");
  15. $langs->load("companies");
  16. $langs->load("other");
  17. // Load permissions
  18. $user->getrights('ecm');
  19. // Get parameters
  20. $socid = isset($_GET["socid"])?$_GET["socid"]:'';
  21. // Permissions
  22. if ($user->societe_id > 0)
  23. {
  24. $action = '';
  25. $socid = $user->societe_id;
  26. }
  27. $section=$_GET["section"];
  28. if (! $section) $section='misc';
  29. $upload_dir = $conf->ecm->dir_output.'/'.$section;
  30. /*******************************************************************
  31. * ACTIONS
  32. *
  33. * Put here all code to do according to value of "action" parameter
  34. ********************************************************************/
  35. // Envoie fichier
  36. if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
  37. {
  38. require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
  39. if (create_exdir($upload_dir) >= 0)
  40. {
  41. $resupload = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0,0,$_FILES['userfile']['error']);
  42. if (is_numeric($resupload) && $resupload > 0)
  43. {
  44. $result=$ecmdir->changeNbOfFiles('+');
  45. }
  46. else
  47. {
  48. $langs->load("errors");
  49. if ($resupload < 0) // Unknown error
  50. {
  51. $mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
  52. }
  53. else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
  54. {
  55. $mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
  56. }
  57. else // Known error
  58. {
  59. $mesg = '<div class="error">'.$langs->trans($resupload).'</div>';
  60. }
  61. }
  62. }
  63. else
  64. {
  65. // Echec transfert (fichier depassant la limite ?)
  66. $langs->load("errors");
  67. $mesg = '<div class="error">'.$langs->trans("ErrorFailToCreateDir",$upload_dir).'</div>';
  68. }
  69. }
  70. // Suppression fichier
  71. if ($_POST['action'] == 'confirm_deletefile' && $_POST['confirm'] == 'yes')
  72. {
  73. $file = $upload_dir . "/" . urldecode($_GET["urlfile"]);
  74. dol_delete_file($file);
  75. $mesg = '<div class="ok">'.$langs->trans("FileWasRemoved").'</div>';
  76. }
  77. /*******************************************************************
  78. * PAGE
  79. *
  80. * Put here all code to do according to value of "action" parameter
  81. ********************************************************************/
  82. llxHeader();
  83. $form=new Form($db);
  84. print_fiche_titre($langs->trans("ECMAutoOrg"));
  85. //$head = societe_prepare_head($societe);
  86. //dol_fiche_head($head, 'document', $societe->nom);
  87. /*
  88. * Confirmation de la suppression d'une ligne produit
  89. */
  90. if ($_GET['action'] == 'delete_file')
  91. {
  92. $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?socid='.$socid.'&amp;urlfile='.urldecode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile');
  93. if ($ret == 'html') print '<br>';
  94. }
  95. // Construit liste des fichiers
  96. clearstatcache();
  97. $totalsize=0;
  98. $filearray=array();
  99. $errorlevel=error_reporting();
  100. error_reporting(0);
  101. $handle=opendir($upload_dir);
  102. error_reporting($errorlevel);
  103. if (is_resource($handle))
  104. {
  105. $i=0;
  106. while (($file = readdir($handle))!==false)
  107. {
  108. if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
  109. {
  110. $filearray[$i]->name=$file;
  111. $filearray[$i]->size=dol_filesize($upload_dir."/".$file);
  112. $filearray[$i]->date=dol_filemtime($upload_dir."/".$file);
  113. $totalsize+=$filearray[$i]->size;
  114. $i++;
  115. }
  116. }
  117. closedir($handle);
  118. }
  119. else
  120. {
  121. // print '<div class="error">'.$langs->trans("ErrorCanNotReadDir",$upload_dir).'</div>';
  122. }
  123. /*
  124. print '<table class="border"width="100%">';
  125. // Nbre fichiers
  126. print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
  127. //Total taille
  128. print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
  129. print '</table>';
  130. print '</div>';
  131. */
  132. if ($mesg) { print $mesg."<br>"; }
  133. print $langs->trans("FeatureNotYetAvailable");
  134. // End of page
  135. $db->close();
  136. llxFooter();
  137. ?>