56 if (!$config[
"file_backed_cache_directory"])
58 $cacheDir =
$config[
"uploadbase"] . DIRECTORY_SEPARATOR .
"cache";
59 if (!is_dir($cacheDir))
64 $config[
"file_backed_cache_directory"] = $cacheDir;
66 $this->cache =
new FileBackedCache();
82 $this->
id = sha1(now() .
$action);
83 foreach($params as $key => $value)
85 $this->
put($key, $value);
88 $launch = $isWindows ?
"start " :
"";
89 $bg = $isWindows ?
"" :
" &";
91 get_include_path().
"' ".
97 $cmd =
"$launch$run ".escapeshellarg(
$home).
" ".escapeshellarg($this->
id).
" ".escapeshellarg(
$action).
" ".
$userPK.
" ".$bg;
99 $this->
put(
"status",
"Starting");
100 $this->
put(
"error",
"");
104 pclose(popen($cmd,
"r"));
109 function put($key, $value)
111 $this->cache->put(
"{$this->id}_{$key}", $value);
116 return $this->cache->get(
"{$this->id}_{$key}");
121 $this->
put(
"status", $status);
123 $this->
put(
"percentage", number_format($percentage, 0));
125 trace(
"{$this->id} $status: $message ($percentage%)", 3);
130 Settings::setDefaultValue(
"process",
"PHP_executable",
"/usr/bin/php", String,
"This is the path to the PHP command line executable");
131 Settings::setDefaultValue(
"process",
"background_process_log_file",
"", String,
"Optionally specify a separate log file for background processes");
137 $mgr->upgrade($version);
static detectWindowsOS()
Returns true if running on Windows, false otherwise.
static getComponent($name)
Return the component record by name.
Provides a central management class for event handlers and common functionality for the process compo...
setProgress($status, $message, $percentage)
static upgradeComponent($version)
run($action, $params=array())
Spawns the specified action as a background process under the current user's credentials.
static getValue($component, $name)
Retrieve the value of the specified Setting.
static setDefaultValue($component, $name, $value, $field_type="String", $annotation="", $category="", $options="", $weight=0)
Sets the default value of the given component setting.
if(php_sapi_name() !="cli") $home