|
From: <gu...@us...> - 2007-05-13 20:26:28
|
Revision: 150
http://svn.sourceforge.net/easybox-mod/?rev=150&view=rev
Author: guyou
Date: 2007-05-13 13:26:26 -0700 (Sun, 13 May 2007)
Log Message:
-----------
Gestion cron
Ajout de fonctions pour manipuler le fichier cron.
Modified Paths:
--------------
trunk/_framework/fonctions_partagees.inc.php
Modified: trunk/_framework/fonctions_partagees.inc.php
===================================================================
--- trunk/_framework/fonctions_partagees.inc.php 2007-05-12 14:42:31 UTC (rev 149)
+++ trunk/_framework/fonctions_partagees.inc.php 2007-05-13 20:26:26 UTC (rev 150)
@@ -15,6 +15,68 @@
save_variable('current_type',$type);
}
+function remove_from_cron($chaine) {
+
+ $cron = '/etc/cron.d/easybox';
+
+ // Par souci de protection on s'assure qu'on n'est pas appele
+ // sur une platfeforme windows
+ if (! (PHP_OS == "WIN32" || PHP_OS == "WINNT")) {
+ // extra protection
+ if (is_writable($cron)) {
+ // On recherche les lignes qui appellent la chaine
+ if ($fp = @fopen($cron,"r+")) {
+ $status=1;
+ $nok=0;
+ $newbuffer = '';
+ while (! feof($fp)) {
+ if ($buffer = @fgets($fp, 4096)) {
+ if (strlen($buffer) > 0) {
+ if (! strstr($buffer, $chaine)) {
+ if ($nok++ == 0) {
+ $newbuffer = $buffer;
+ } else {
+ $newbuffer .= $buffer;
+ }
+ }
+ }
+ } else {
+ $status=0;
+ break;
+ }
+ }
+ if ($status == 0) {
+ if (@rewind($fp)) {
+ if (@fwrite($fp, $newbuffer)) {
+ @ftruncate($fp, strlen($newbuffer));
+ }
+ }
+ }
+ @fclose($fp);
+ }
+ }
+ }
+}
+
+function add_to_cron($fichier1, $deb, $fichier2, $end) {
+ $cron = '/etc/cron.d/easybox';
+
+ // Par souci de protection on s'assure qu'on n'est pas appele
+ // sur une platfeforme windows
+ if (! (PHP_OS == "WIN32" || PHP_OS == "WINNT")) {
+ // extra protection
+ if (is_writable($cron)) {
+
+ if ($fp = @fopen('/etc/cron.d/easybox',"a+")) {
+ @fputs($fp, date("i", $deb).' '.date("H", $deb).' '.date("j", $deb).' '.date("n", $deb)." * www-data /bin/sh '".$fichier1."'\n");
+ @fputs($fp, date("i", $end).' '.date("H", $end).' '.date("j", $end).' '.date("n", $end)." * www-data /bin/sh '".$fichier2."'\n");
+ @fclose($fp);
+ }
+ }
+ }
+}
+
+
function supprime_accents($chaine) {
$a = "\xE0\xE1\xE2\xE3\xE4\xE5\xF2\xF3\xF4\xF5\xF6\xF8\xE8\xE9\xEA\xEB\xE7\xEC\xED\xEE\xEF\xF9\xFA\xFB\xFC\xFF\xF1";
$b = "aaaaaaooooooeeeeciiiiuuuuyn";
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|