Go to the source code of this file.
|
| d ($mess) |
| Debug function that print infos. More...
|
|
| mail_it () |
| Function to mail the panel's administrator if something failed. More...
|
|
| execute_cmd ($command, $parameters=array()) |
| Common routine for system calls. More...
|
|
| my_realpath ($path) |
| Check if a file or folder is in the list of allowed path (after dereferencing all ../ and symlinks. More...
|
|
|
| $debug =0 |
| This script check the MySQL DB for actions to do, and do them one by one. More...
|
|
| $errorsList =array() |
|
if(!defined("ALTERNC_DO_ACTION_LOCK")) | $SCRIPT ='/usr/bin/php do_actions.php' |
|
| $MY_PID =getmypid() |
|
| $FIXPERM ='/usr/lib/alternc/fixperms.sh' |
|
if(file_exists(ALTERNC_DO_ACTION_LOCK) !==false) | else |
|
◆ d()
Debug function that print infos.
- Parameters
-
| global | int $debug |
type | $mess | |
Definition at line 75 of file do_actions.php.
$debug
This script check the MySQL DB for actions to do, and do them one by one.
References $debug.
◆ execute_cmd()
execute_cmd |
( |
|
$command, |
|
|
|
$parameters = array() |
|
) |
| |
Common routine for system calls.
- Parameters
-
type | $command | the command |
type | $parameters | of the command (they are going to be protected) |
- Returns
- array('output'=>'output of exec', 'return_val'=>'returned integer of exec')
Definition at line 106 of file do_actions.php.
107 $cmd_line =
"$command ";
108 if (!empty($parameters)) {
109 if (is_array($parameters)) {
110 foreach($parameters as $pp) {
111 $cmd_line.=
" ".escapeshellarg($pp).
" ";
114 $cmd_line.=
" ".escapeshellarg($parameters).
" " ;
118 exec($cmd_line, $output, $code);
119 return array(
'executed' => $cmd_line,
'output'=>$output,
'return_val'=>$code);
◆ mail_it()
Function to mail the panel's administrator if something failed.
- Parameters
-
global | array $errorsList |
global | type $L_FQDN |
Definition at line 86 of file do_actions.php.
96 mail(
"alterncpanel@$L_FQDN",
'Script do_actions.php issues',
"\n Errors reporting mail:\n\n$msg");
References $errorsList, and $msg.
◆ my_realpath()
Check if a file or folder is in the list of allowed path (after dereferencing all ../ and symlinks.
- Parameters
-
$path | string the path to check against |
- Returns
- string the dereferenced path, or FALSE if the path is NOT allowed (/var/www/alternc /var/mail/alternc)
Definition at line 127 of file do_actions.php.
128 global $L_ALTERNC_HTML, $L_ALTERNC_MAIL;
130 $allowed=array(realpath($L_ALTERNC_HTML).
"/", realpath($L_ALTERNC_MAIL).
"/");
131 $path=realpath($path);
132 foreach($allowed as $one) {
134 if (strlen($path)>strlen($one) && substr($path,0,strlen($one))==$one) {
142 if (file_exists(ALTERNC_DO_ACTION_LOCK) !==
false){
143 d(
"Lock file already exists. ");
145 $PID=file_get_contents(ALTERNC_DO_ACTION_LOCK);
146 d(
"My PID is $MY_PID, PID in the lock file is $PID");
147 if ($PID == exec(
"pidof $SCRIPT | tr ' ' '\n' | grep -v $MY_PID")){
149 d(
"Previous cron is already running, we just exit and let it finish :-)");
153 $errorsList[]=
"Lock file already exists. No process with PID $PID found! Previous cron failed...\n";
161 if (file_put_contents(ALTERNC_DO_ACTION_LOCK,
$MY_PID) ===
false){
162 $errorsList[]=
"Cannot open/write ALTERNC_DO_ACTION_LOCK\n";
169 while($cc=$action->get_job()){
171 $params=unserialize(
$c[
"parameters"]);
173 d(
"Previous job was the n°".
$c[
"id"].
" : '".
$c[
"type"].
"'");
174 if(
$c[
"type"] ==
"CREATE_FILE" && is_dir(dirname($params[
"file"])) ||
$c[
"type"] ==
"CREATE_DIR" ||
$c[
"type"] ==
"DELETE" ||
$c[
"type"] ==
"FIX_DIR" ||
$c[
"type"] ==
"FIX_FILE"){
175 d(
"Reset of the job! So it will be resumed...");
176 $action->reset_job(
$c[
"id"]);
179 $errorsList[]=
"Can't resume the job n°".$c[
"id"].
" action '".
$c[
"type"].
"', finishing it with a fail status.\n";
180 if(!$action->finish(
$c[
"id"],
"Fail: Previous script crashed while processing this action, cannot resume it.")){
181 $errorsList[]=
"Cannot finish the action! Error while inserting the error value in the DB for action n°".$c[
"id"].
" : action '".
$c[
"type"].
"'\n";
d($mess)
Debug function that print infos.
mail_it()
Function to mail the panel's administrator if something failed.
◆ $debug
This script check the MySQL DB for actions to do, and do them one by one.
- Copyright
- AlternC-Team 2002-2013 http://alternc.org/
Definition at line 48 of file do_actions.php.
Referenced by d().
◆ $errorsList
◆ $FIXPERM
$FIXPERM ='/usr/lib/alternc/fixperms.sh' |
◆ $MY_PID
◆ $SCRIPT
if (!defined("ALTERNC_DO_ACTION_LOCK")) $SCRIPT ='/usr/bin/php do_actions.php' |
◆ else
if (file_exists(ALTERNC_DO_ACTION_LOCK) !==false) else |