define ( 'FRIENDICA_CODENAME', 'Asparagus');
define ( 'FRIENDICA_VERSION', '3.5.1-dev' );
define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
-define ( 'DB_UPDATE_VERSION', 1213 );
+define ( 'DB_UPDATE_VERSION', 1214 );
/**
* @brief Constant with a HTML line break.
define ( 'NETWORK_APPNET', 'apdn'); // app.net
define ( 'NETWORK_NEWS', 'nntp'); // Network News Transfer Protocol
define ( 'NETWORK_ICALENDAR', 'ical'); // iCalendar
+define ( 'NETWORK_PNUT', 'pnut'); // pnut.io
define ( 'NETWORK_PHANTOM', 'unkn'); // Place holder
/** @}*/
NETWORK_APPNET => (-17),
NETWORK_NEWS => (-18),
NETWORK_ICALENDAR => (-19),
+ NETWORK_PNUT => (-20),
NETWORK_PHANTOM => (-127),
);
define('PRIORITY_NEGLIGIBLE',50);
/* @}*/
+/**
+ * @name Social Relay settings
+ *
+ * See here: https://github.com/jaywink/social-relay
+ * and here: https://wiki.diasporafoundation.org/Relay_servers_for_public_posts
+ * @{
+ */
+define('SR_SCOPE_NONE', '');
+define('SR_SCOPE_ALL', 'all');
+define('SR_SCOPE_TAGS', 'tags');
+/* @}*/
// Normally this constant is defined - but not if "pcntl" isn't installed
if (!defined("SIGTERM"))
proc_close(proc_open($cmdline." &",array(),$foo,dirname(__FILE__)));
}
+
+ /**
+ * @brief Returns the system user that is executing the script
+ *
+ * This mostly returns something like "www-data".
+ *
+ * @return string system username
+ */
+ static function systemuser() {
+ if (!function_exists('posix_getpwuid') OR !function_exists('posix_geteuid')) {
+ return '';
+ }
+
+ $processUser = posix_getpwuid(posix_geteuid());
+ return $processUser['name'];
+ }
+
+ /**
+ * @brief Checks if a given directory is usable for the system
+ *
+ * @return boolean the directory is usable
+ */
+ static function directory_usable($directory) {
+
+ if ($directory == '') {
+ logger("Directory is empty. This shouldn't happen.", LOGGER_DEBUG);
+ return false;
+ }
+
+ if (!file_exists($directory)) {
+ logger('Path "'.$directory.'" does not exist for user '.self::systemuser(), LOGGER_DEBUG);
+ return false;
+ }
+ if (is_file($directory)) {
+ logger('Path "'.$directory.'" is a file for user '.self::systemuser(), LOGGER_DEBUG);
+ return false;
+ }
+ if (!is_dir($directory)) {
+ logger('Path "'.$directory.'" is not a directory for user '.self::systemuser(), LOGGER_DEBUG);
+ return false;
+ }
+ if (!is_writable($directory)) {
+ logger('Path "'.$directory.'" is not writable for user '.self::systemuser(), LOGGER_DEBUG);
+ return false;
+ }
+ return true;
+ }
}
/**
return "";
$itemcache = get_config('system','itemcache');
- if (($itemcache != "") AND is_dir($itemcache) AND is_writable($itemcache))
- return($itemcache);
+ if (($itemcache != "") AND App::directory_usable($itemcache)) {
+ return $itemcache;
+ }
$temppath = get_temppath();
mkdir($itemcache);
}
- if (is_dir($itemcache) AND is_writable($itemcache)) {
+ if (App::directory_usable($itemcache)) {
set_config("system", "itemcache", $itemcache);
- return($itemcache);
+ return $itemcache;
}
}
return "";
function get_lockpath() {
$lockpath = get_config('system','lockpath');
- if (($lockpath != "") AND is_dir($lockpath) AND is_writable($lockpath))
- return($lockpath);
+ if (($lockpath != "") AND App::directory_usable($lockpath)) {
+ // We have a lock path and it is usable
+ return $lockpath;
+ }
+ // We don't have a working preconfigured lock path, so we take the temp path.
$temppath = get_temppath();
if ($temppath != "") {
+ // To avoid any interferences with other systems we create our own directory
$lockpath = $temppath."/lock";
-
- if (!is_dir($lockpath))
+ if (!is_dir($lockpath)) {
mkdir($lockpath);
- elseif (!is_writable($lockpath))
- $lockpath = $temppath;
+ }
- if (is_dir($lockpath) AND is_writable($lockpath)) {
+ if (App::directory_usable($lockpath)) {
+ // The new path is usable, we are happy
set_config("system", "lockpath", $lockpath);
- return($lockpath);
+ return $lockpath;
+ } else {
+ // We can't create a subdirectory, strange.
+ // But the directory seems to work, so we use it but don't store it.
+ return $temppath;
}
}
+
+ // Reaching this point means that the operating system is configured badly.
return "";
}
*/
function get_spoolpath() {
$spoolpath = get_config('system','spoolpath');
- if (($spoolpath != "") AND is_dir($spoolpath) AND is_writable($spoolpath)) {
- return($spoolpath);
+ if (($spoolpath != "") AND App::directory_usable($spoolpath)) {
+ // We have a spool path and it is usable
+ return $spoolpath;
}
+ // We don't have a working preconfigured spool path, so we take the temp path.
$temppath = get_temppath();
if ($temppath != "") {
+ // To avoid any interferences with other systems we create our own directory
$spoolpath = $temppath."/spool";
-
if (!is_dir($spoolpath)) {
mkdir($spoolpath);
- } elseif (!is_writable($spoolpath)) {
- $spoolpath = $temppath;
}
- if (is_dir($spoolpath) AND is_writable($spoolpath)) {
+ if (App::directory_usable($spoolpath)) {
+ // The new path is usable, we are happy
set_config("system", "spoolpath", $spoolpath);
- return($spoolpath);
+ return $spoolpath;
+ } else {
+ // We can't create a subdirectory, strange.
+ // But the directory seems to work, so we use it but don't store it.
+ return $temppath;
}
}
+
+ // Reaching this point means that the operating system is configured badly.
return "";
}
function get_temppath() {
$a = get_app();
- $temppath = get_config("system","temppath");
- if (($temppath != "") AND is_dir($temppath) AND is_writable($temppath))
- return($temppath);
+ $temppath = get_config("system", "temppath");
+ if (($temppath != "") AND App::directory_usable($temppath)) {
+ // We have a temp path and it is usable
+ return $temppath;
+ }
+
+ // We don't have a working preconfigured temp path, so we take the system path.
$temppath = sys_get_temp_dir();
- if (($temppath != "") AND is_dir($temppath) AND is_writable($temppath)) {
- $temppath .= "/".$a->get_hostname();
- if (!is_dir($temppath))
- mkdir($temppath);
-
- if (is_dir($temppath) AND is_writable($temppath)) {
- set_config("system", "temppath", $temppath);
- return($temppath);
+
+ // Check if it is usable
+ if (($temppath != "") AND App::directory_usable($temppath)) {
+ // To avoid any interferences with other systems we create our own directory
+ $new_temppath .= "/".$a->get_hostname();
+ if (!is_dir($new_temppath))
+ mkdir($new_temppath);
+
+ if (App::directory_usable($new_temppath)) {
+ // The new path is usable, we are happy
+ set_config("system", "temppath", $new_temppath);
+ return $new_temppath;
+ } else {
+ // We can't create a subdirectory, strange.
+ // But the directory seems to work, so we use it but don't store it.
+ return $temppath;
}
}
- return("");
+ // Reaching this point means that the operating system is configured badly.
+ return '';
}
/// @deprecated