cron.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?php
  2. /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.org>
  4. * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
  5. * Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
  6. * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. /**
  22. * \file cron/admin/cron.php
  23. * \ingroup cron
  24. */
  25. // Dolibarr environment
  26. $res = @include("../../main.inc.php"); // From htdocs directory
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/cron.lib.php';
  29. $langs->load("admin");
  30. $langs->load("cron");
  31. if (! $user->admin)
  32. accessforbidden();
  33. $actionsave=GETPOST("save");
  34. // Save parameters
  35. if (!empty($actionsave))
  36. {
  37. $i=0;
  38. $db->begin();
  39. $i+=dolibarr_set_const($db,'CRON_KEY',trim(GETPOST("CRON_KEY")),'chaine',0,'',0);
  40. if ($i >= 1)
  41. {
  42. $db->commit();
  43. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  44. }
  45. else
  46. {
  47. $db->rollback();
  48. setEventMessages($langs->trans("Error"), null, 'errors');
  49. }
  50. }
  51. /*
  52. * View
  53. */
  54. llxHeader();
  55. $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
  56. print load_fiche_titre($langs->trans("CronSetup"),$linkback,'title_setup');
  57. // Configuration header
  58. $head = cronadmin_prepare_head();
  59. print '<form name="agendasetupform" action="'.$_SERVER["PHP_SELF"].'" method="post">';
  60. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  61. dol_fiche_head($head,'setup',$langs->trans("Module2300Name"),0,'cron');
  62. print "<br>\n";
  63. print '<table class="noborder" width="100%">';
  64. print '<tr class="liste_titre">';
  65. print "<td>".$langs->trans("Parameter")."</td>";
  66. print "<td>".$langs->trans("Value")."</td>";
  67. print "<td>&nbsp;</td>";
  68. print "</tr>";
  69. print '<tr class="impair">';
  70. print '<td class="fieldrequired">'.$langs->trans("KeyForCronAccess").'</td>';
  71. $disabled='';
  72. if (! empty($conf->global->CRON_DISABLE_KEY_CHANGE)) $disabled=' disabled="disabled"';
  73. print '<td>';
  74. if (empty($conf->global->CRON_DISABLE_KEY_CHANGE))
  75. {
  76. print '<input type="text" class="flat minwidth200"'.$disabled.' id="CRON_KEY" name="CRON_KEY" value="'. (GETPOST('CRON_KEY')?GETPOST('CRON_KEY'):(! empty($conf->global->CRON_KEY)?$conf->global->CRON_KEY:'')) . '">';
  77. if (! empty($conf->use_javascript_ajax))
  78. print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
  79. }
  80. else
  81. {
  82. print (! empty($conf->global->CRON_KEY)?$conf->global->CRON_KEY:'');
  83. print '<input type="hidden" id="CRON_KEY" name="CRON_KEY" value="'. (GETPOST('CRON_KEY')?GETPOST('CRON_KEY'):(! empty($conf->global->CRON_KEY)?$conf->global->CRON_KEY:'')) . '">';
  84. }
  85. print '</td>';
  86. print '<td>&nbsp;</td>';
  87. print '</tr>';
  88. print '</table>';
  89. dol_fiche_end();
  90. print '<div class="center">';
  91. print '<input type="submit" name="save" class="button" value="'.$langs->trans("Save").'">';
  92. print '</div>';
  93. print '</form>';
  94. print '<br><br>';
  95. print $langs->trans("UseMenuModuleToolsToAddCronJobs").'<br>';
  96. if (! empty($conf->global->CRON_WARNING_DELAY_HOURS)) print info_admin($langs->trans("WarningCronDelayed", $conf->global->CRON_WARNING_DELAY_HOURS));
  97. print '<br><br>';
  98. dol_print_cron_urls();
  99. print '<br>';
  100. if (! empty($conf->use_javascript_ajax))
  101. {
  102. print "\n".'<script type="text/javascript">';
  103. print '$(document).ready(function () {
  104. $("#generate_token").click(function() {
  105. $.get( "'.DOL_URL_ROOT.'/core/ajax/security.php", {
  106. action: \'getrandompassword\',
  107. generic: true
  108. },
  109. function(token) {
  110. $("#CRON_KEY").val(token);
  111. });
  112. });
  113. });';
  114. print '</script>';
  115. }
  116. llxFooter();
  117. $db->close();