define ( 'FRIENDICA_CODENAME', 'Lily of the valley');
define ( 'FRIENDICA_VERSION', '3.4.1' );
define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
-define ( 'DB_UPDATE_VERSION', 1187 );
+define ( 'DB_UPDATE_VERSION', 1189 );
define ( 'EOL', "<br />\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
define ( 'LOGGER_DATA', 3 );
define ( 'LOGGER_ALL', 4 );
+/**
+ * cache levels
+ */
+
+define ( 'CACHE_MONTH', 0 );
+define ( 'CACHE_WEEK', 1 );
+define ( 'CACHE_DAY', 2 );
+define ( 'CACHE_HOUR', 3 );
+
/**
* registration policies
*/
if(! $arr['run_cmd'])
return;
- if(count($args) && $args[0] === 'php')
+ if(count($args) && $args[0] === 'php') {
+
+ if (get_config("system", "worker")) {
+ $argv = $args;
+ array_shift($argv);
+
+ $parameters = json_encode($argv);
+ $found = q("SELECT `id` FROM `workerqueue` WHERE `parameter` = '%s'",
+ dbesc($parameters));
+
+ if (!$found)
+ q("INSERT INTO `workerqueue` (`parameter`, `created`, `priority`)
+ VALUES ('%s', '%s', %d)",
+ dbesc($parameters),
+ dbesc(datetime_convert()),
+ intval(0));
+
+ // Should we quit and wait for the poller to be called as a cronjob?
+ if (get_config("system", "worker_dont_fork"))
+ return;
+
+ // Checking number of workers
+ $workers = q("SELECT COUNT(*) AS `workers` FROM `workerqueue` WHERE `executed` != '0000-00-00 00:00:00'");
+
+ // Get number of allowed number of worker threads
+ $queues = intval(get_config("system", "worker_queues"));
+
+ if ($queues == 0)
+ $queues = 4;
+
+ // If there are already enough workers running, don't fork another one
+ if ($workers[0]["workers"] >= $queues)
+ return;
+
+ // Now call the poller to execute the jobs that we just added to the queue
+ $args = array("php", "include/poller.php", "no_cron");
+ }
+
$args[0] = ((x($a->config,'php_path')) && (strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
+ }
// add baseurl to args. cli scripts can't construct it
$args[] = $a->get_baseurl();
for($x = 0; $x < count($args); $x ++)
$args[$x] = escapeshellarg($args[$x]);
-
-
$cmdline = implode($args," ");
+
if(get_config('system','proc_windows'))
proc_close(proc_open('cmd /c start /b ' . $cmdline,array(),$foo,dirname(__FILE__)));
else
return($size[2]);
}
}
+
+function validate_include(&$file) {
+ $orig_file = $file;
+
+ $file = realpath($file);
+
+ if (strpos($file, getcwd()) !== 0)
+ return false;
+
+ $file = str_replace(getcwd()."/", "", $file, $count);
+ if ($count != 1)
+ return false;
+
+ if ($orig_file !== $file)
+ return false;
+
+ $valid = false;
+ if (strpos($file, "include/") === 0)
+ $valid = true;
+
+ if (strpos($file, "addon/") === 0)
+ $valid = true;
+
+ if (!$valid)
+ return false;
+
+ return true;
+}