5 use Friendica\Core\System;
6 use Friendica\Core\Cache;
7 use Friendica\Core\Config;
8 use Friendica\Core\PConfig;
9 use Friendica\Database\DBM;
13 use Detection\MobileDetect;
17 require_once 'boot.php';
18 require_once 'include/dba.php';
24 * @brief Our main application structure for the life of this page.
26 * Primarily deals with the URL that got us here
27 * and tries to make some sense of it, and
28 * stores our page contents and config storage
29 * and anything else that might need to be passed around
30 * before we spit the page out.
35 public $module_loaded = false;
36 public $module_class = null;
48 public $data = array();
49 public $error = false;
60 public $interactive = true;
62 public $apps = array();
64 public $is_mobile = false;
65 public $is_tablet = false;
66 public $is_friendica_app;
67 public $performance = array();
68 public $callstack = array();
69 public $theme_info = array();
70 public $backend = true;
73 // Allow themes to control internal parameters
74 // by changing App values in theme.php
76 public $sourcename = '';
77 public $videowidth = 425;
78 public $videoheight = 350;
79 public $force_max_items = 0;
80 public $theme_events_in_profile = true;
83 * @brief An array for all theme-controllable parameters
85 * Mostly unimplemented yet. Only options 'template_engine' and
88 public $theme = array(
92 'force_max_items' => 0,
94 'template_engine' => 'smarty3',
98 * @brief An array of registered template engines ('name'=>'class name')
100 public $template_engines = array();
103 * @brief An array of instanced template engines ('name'=>'instance')
105 public $template_engine_instance = array();
108 private $ldelim = array(
112 private $rdelim = array(
120 private $curl_content_type;
121 private $curl_headers;
122 private $cached_profile_image;
123 private $cached_profile_picdate;
127 * @brief App constructor.
129 * @param string $basepath Path to the app base folder
131 function __construct($basepath) {
133 global $default_timezone;
137 if (! static::directory_usable($basepath, false)) {
138 throw new Exception('Basepath ' . $basepath . ' isn\'t usable.');
141 $this->basepath = rtrim($basepath, DIRECTORY_SEPARATOR);
143 if (file_exists($this->basepath.DIRECTORY_SEPARATOR.'.htpreconfig.php')) {
144 include $this->basepath.DIRECTORY_SEPARATOR.'.htpreconfig.php';
147 $this->timezone = ((x($default_timezone)) ? $default_timezone : 'UTC');
149 date_default_timezone_set($this->timezone);
151 $this->performance['start'] = microtime(true);
152 $this->performance['database'] = 0;
153 $this->performance['database_write'] = 0;
154 $this->performance['network'] = 0;
155 $this->performance['file'] = 0;
156 $this->performance['rendering'] = 0;
157 $this->performance['parser'] = 0;
158 $this->performance['marktime'] = 0;
159 $this->performance['markstart'] = microtime(true);
161 $this->callstack['database'] = array();
162 $this->callstack['database_write'] = array();
163 $this->callstack['network'] = array();
164 $this->callstack['file'] = array();
165 $this->callstack['rendering'] = array();
166 $this->callstack['parser'] = array();
168 $this->config = array();
169 $this->page = array();
170 $this->pager = array();
172 $this->query_string = '';
174 $this->process_id = uniqid('log', true);
178 $this->scheme = 'http';
180 if ((x($_SERVER, 'HTTPS') && $_SERVER['HTTPS']) ||
181 (x($_SERVER, 'HTTP_FORWARDED') && preg_match('/proto=https/', $_SERVER['HTTP_FORWARDED'])) ||
182 (x($_SERVER, 'HTTP_X_FORWARDED_PROTO') && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') ||
183 (x($_SERVER, 'HTTP_X_FORWARDED_SSL') && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') ||
184 (x($_SERVER, 'FRONT_END_HTTPS') && $_SERVER['FRONT_END_HTTPS'] == 'on') ||
185 (x($_SERVER, 'SERVER_PORT') && (intval($_SERVER['SERVER_PORT']) == 443)) // XXX: reasonable assumption, but isn't this hardcoding too much?
187 $this->scheme = 'https';
190 if (x($_SERVER, 'SERVER_NAME')) {
191 $this->hostname = $_SERVER['SERVER_NAME'];
193 if (x($_SERVER, 'SERVER_PORT') && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) {
194 $this->hostname .= ':' . $_SERVER['SERVER_PORT'];
197 * Figure out if we are running at the top of a domain
198 * or in a sub-directory and adjust accordingly
201 /// @TODO This kind of escaping breaks syntax-highlightning on CoolEdit (Midnight Commander)
202 $path = trim(dirname($_SERVER['SCRIPT_NAME']), '/\\');
203 if (isset($path) && strlen($path) && ($path != $this->path)) {
208 if ($hostname != '') {
209 $this->hostname = $hostname;
213 get_include_path() . PATH_SEPARATOR
214 . $this->basepath . DIRECTORY_SEPARATOR . 'include' . PATH_SEPARATOR
215 . $this->basepath . DIRECTORY_SEPARATOR . 'library' . PATH_SEPARATOR
219 if (is_array($_SERVER['argv']) && $_SERVER['argc'] > 1 && substr(end($_SERVER['argv']), 0, 4) == 'http') {
220 $this->set_baseurl(array_pop($_SERVER['argv']));
224 if ((x($_SERVER, 'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'], 0, 9) === 'pagename=') {
225 $this->query_string = substr($_SERVER['QUERY_STRING'], 9);
227 // removing trailing / - maybe a nginx problem
228 $this->query_string = ltrim($this->query_string, '/');
229 } elseif ((x($_SERVER, 'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'], 0, 2) === 'q=') {
230 $this->query_string = substr($_SERVER['QUERY_STRING'], 2);
232 // removing trailing / - maybe a nginx problem
233 $this->query_string = ltrim($this->query_string, '/');
236 if (x($_GET, 'pagename')) {
237 $this->cmd = trim($_GET['pagename'], '/\\');
238 } elseif (x($_GET, 'q')) {
239 $this->cmd = trim($_GET['q'], '/\\');
243 $this->query_string = str_replace($this->cmd . '&', $this->cmd . '?', $this->query_string);
245 // unix style "homedir"
246 if (substr($this->cmd, 0, 1) === '~') {
247 $this->cmd = 'profile/' . substr($this->cmd, 1);
250 // Diaspora style profile url
251 if (substr($this->cmd, 0, 2) === 'u/') {
252 $this->cmd = 'profile/' . substr($this->cmd, 2);
256 * Break the URL path into C style argc/argv style arguments for our
257 * modules. Given "http://example.com/module/arg1/arg2", $this->argc
258 * will be 3 (integer) and $this->argv will contain:
264 * There will always be one argument. If provided a naked domain
265 * URL, $this->argv[0] is set to "home".
268 $this->argv = explode('/', $this->cmd);
269 $this->argc = count($this->argv);
270 if ((array_key_exists('0', $this->argv)) && strlen($this->argv[0])) {
271 $this->module = str_replace('.', '_', $this->argv[0]);
272 $this->module = str_replace('-', '_', $this->module);
275 $this->argv = array('home');
276 $this->module = 'home';
279 // See if there is any page number information, and initialise pagination
280 $this->pager['page'] = ((x($_GET, 'page') && intval($_GET['page']) > 0) ? intval($_GET['page']) : 1);
281 $this->pager['itemspage'] = 50;
282 $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];
284 if ($this->pager['start'] < 0) {
285 $this->pager['start'] = 0;
287 $this->pager['total'] = 0;
289 // Detect mobile devices
290 $mobile_detect = new MobileDetect();
291 $this->is_mobile = $mobile_detect->isMobile();
292 $this->is_tablet = $mobile_detect->isTablet();
295 $this->is_friendica_app = ($_SERVER['HTTP_USER_AGENT'] == 'Apache-HttpClient/UNAVAILABLE (java 1.4)');
297 // Register template engines
298 $dc = get_declared_classes();
299 foreach ($dc as $k) {
300 if (in_array('Friendica\Render\ITemplateEngine', class_implements($k))) {
301 $this->register_template_engine($k);
309 * @brief Returns the base filesystem path of the App
311 * It first checks for the internal variable, then for DOCUMENT_ROOT and
316 public function get_basepath() {
317 $basepath = $this->basepath;
320 $basepath = Config::get('system', 'basepath');
323 if (! $basepath && x($_SERVER, 'DOCUMENT_ROOT')) {
324 $basepath = $_SERVER['DOCUMENT_ROOT'];
327 if (! $basepath && x($_SERVER, 'PWD')) {
328 $basepath = $_SERVER['PWD'];
331 return self::realpath($basepath);
335 * @brief Returns a normalized file path
337 * This is a wrapper for the "realpath" function.
338 * That function cannot detect the real path when some folders aren't readable.
339 * Since this could happen with some hosters we need to handle this.
341 * @param string $path The path that is about to be normalized
342 * @return string normalized path - when possible
344 public static function realpath($path) {
345 $normalized = realpath($path);
347 if (!is_bool($normalized)) {
354 function get_scheme() {
355 return $this->scheme;
359 * @brief Retrieves the Friendica instance base URL
361 * This function assembles the base URL from multiple parts:
362 * - Protocol is determined either by the request or a combination of
363 * system.ssl_policy and the $ssl parameter.
364 * - Host name is determined either by system.hostname or inferred from request
365 * - Path is inferred from SCRIPT_NAME
367 * Note: $ssl parameter value doesn't directly correlate with the resulting protocol
369 * @param bool $ssl Whether to append http or https under SSL_POLICY_SELFSIGN
370 * @return string Friendica server base URL
372 function get_baseurl($ssl = false) {
373 $scheme = $this->scheme;
375 if (Config::get('system', 'ssl_policy') == SSL_POLICY_FULL) {
379 // Basically, we have $ssl = true on any links which can only be seen by a logged in user
380 // (and also the login link). Anything seen by an outsider will have it turned off.
382 if (Config::get('system', 'ssl_policy') == SSL_POLICY_SELFSIGN) {
390 if (Config::get('config', 'hostname') != '') {
391 $this->hostname = Config::get('config', 'hostname');
394 return $scheme . '://' . $this->hostname . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : '' );
398 * @brief Initializes the baseurl components
400 * Clears the baseurl cache to prevent inconstistencies
404 function set_baseurl($url) {
405 $parsed = @parse_url($url);
408 $this->scheme = $parsed['scheme'];
410 $hostname = $parsed['host'];
411 if (x($parsed, 'port')) {
412 $hostname .= ':' . $parsed['port'];
414 if (x($parsed, 'path')) {
415 $this->path = trim($parsed['path'], '\\/');
418 if (file_exists($this->basepath.DIRECTORY_SEPARATOR.'.htpreconfig.php')) {
419 include $this->basepath.DIRECTORY_SEPARATOR.'.htpreconfig.php';
422 if (Config::get('config', 'hostname') != '') {
423 $this->hostname = Config::get('config', 'hostname');
426 if (!isset($this->hostname) || ( $this->hostname == '')) {
427 $this->hostname = $hostname;
432 function get_hostname() {
433 if (Config::get('config', 'hostname') != '') {
434 $this->hostname = Config::get('config', 'hostname');
437 return $this->hostname;
440 function set_hostname($h) {
441 $this->hostname = $h;
444 function set_path($p) {
445 $this->path = trim(trim($p), '/');
448 function get_path() {
452 function set_pager_total($n) {
453 $this->pager['total'] = intval($n);
456 function set_pager_itemspage($n) {
457 $this->pager['itemspage'] = ((intval($n) > 0) ? intval($n) : 0);
458 $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];
461 function set_pager_page($n) {
462 $this->pager['page'] = $n;
463 $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];
466 function init_pagehead() {
467 $interval = ((local_user()) ? PConfig::get(local_user(), 'system', 'update_interval') : 40000);
469 // If the update is 'deactivated' set it to the highest integer number (~24 days)
471 $interval = 2147483647;
474 if ($interval < 10000) {
478 // compose the page title from the sitename and the
479 // current module called
480 if (!$this->module == '') {
481 $this->page['title'] = $this->config['sitename'] . ' (' . $this->module . ')';
483 $this->page['title'] = $this->config['sitename'];
486 /* put the head template at the beginning of page['htmlhead']
487 * since the code added by the modules frequently depends on it
490 if (!isset($this->page['htmlhead'])) {
491 $this->page['htmlhead'] = '';
494 // If we're using Smarty, then doing replace_macros() will replace
495 // any unrecognized variables with a blank string. Since we delay
496 // replacing $stylesheet until later, we need to replace it now
497 // with another variable name
498 if ($this->theme['template_engine'] === 'smarty3') {
499 $stylesheet = $this->get_template_ldelim('smarty3') . '$stylesheet' . $this->get_template_rdelim('smarty3');
501 $stylesheet = '$stylesheet';
504 $shortcut_icon = Config::get('system', 'shortcut_icon');
505 if ($shortcut_icon == '') {
506 $shortcut_icon = 'images/friendica-32.png';
509 $touch_icon = Config::get('system', 'touch_icon');
510 if ($touch_icon == '') {
511 $touch_icon = 'images/friendica-128.png';
514 // get data wich is needed for infinite scroll on the network page
515 $invinite_scroll = infinite_scroll_data($this->module);
517 $tpl = get_markup_template('head.tpl');
518 $this->page['htmlhead'] = replace_macros($tpl, array(
519 '$baseurl' => $this->get_baseurl(),
520 '$local_user' => local_user(),
521 '$generator' => 'Friendica' . ' ' . FRIENDICA_VERSION,
522 '$delitem' => t('Delete this item?'),
523 '$showmore' => t('show more'),
524 '$showfewer' => t('show fewer'),
525 '$update_interval' => $interval,
526 '$shortcut_icon' => $shortcut_icon,
527 '$touch_icon' => $touch_icon,
528 '$stylesheet' => $stylesheet,
529 '$infinite_scroll' => $invinite_scroll,
530 )) . $this->page['htmlhead'];
533 function init_page_end() {
534 if (!isset($this->page['end'])) {
535 $this->page['end'] = '';
537 $tpl = get_markup_template('end.tpl');
538 $this->page['end'] = replace_macros($tpl, array(
539 '$baseurl' => $this->get_baseurl()
540 )) . $this->page['end'];
543 function set_curl_code($code) {
544 $this->curl_code = $code;
547 function get_curl_code() {
548 return $this->curl_code;
551 function set_curl_content_type($content_type) {
552 $this->curl_content_type = $content_type;
555 function get_curl_content_type() {
556 return $this->curl_content_type;
559 function set_curl_headers($headers) {
560 $this->curl_headers = $headers;
563 function get_curl_headers() {
564 return $this->curl_headers;
567 function get_cached_avatar_image($avatar_image) {
568 return $avatar_image;
572 * @brief Removes the baseurl from an url. This avoids some mixed content problems.
574 * @param string $orig_url
576 * @return string The cleaned url
578 function remove_baseurl($orig_url) {
580 // Remove the hostname from the url if it is an internal link
581 $nurl = normalise_link($orig_url);
582 $base = normalise_link($this->get_baseurl());
583 $url = str_replace($base . '/', '', $nurl);
585 // if it is an external link return the orignal value
586 if ($url == normalise_link($orig_url)) {
594 * @brief Register template engine class
596 * If $name is '', is used class static property $class::$name
598 * @param string $class
599 * @param string $name
601 function register_template_engine($class, $name = '') {
602 /// @TODO Really === and not just == ?
604 $v = get_class_vars($class);
609 echo "template engine <tt>$class</tt> cannot be registered without a name.\n";
612 $this->template_engines[$name] = $class;
616 * @brief Return template engine instance.
618 * If $name is not defined, return engine defined by theme,
621 * @param string $name Template engine name
622 * @return object Template Engine instance
624 function template_engine($name = '') {
625 /// @TODO really type-check included?
627 $template_engine = $name;
629 $template_engine = 'smarty3';
630 if (x($this->theme, 'template_engine')) {
631 $template_engine = $this->theme['template_engine'];
635 if (isset($this->template_engines[$template_engine])) {
636 if (isset($this->template_engine_instance[$template_engine])) {
637 return $this->template_engine_instance[$template_engine];
639 $class = $this->template_engines[$template_engine];
641 $this->template_engine_instance[$template_engine] = $obj;
646 echo "template engine <tt>$template_engine</tt> is not registered!\n";
651 * @brief Returns the active template engine.
655 function get_template_engine() {
656 return $this->theme['template_engine'];
659 function set_template_engine($engine = 'smarty3') {
660 $this->theme['template_engine'] = $engine;
663 function get_template_ldelim($engine = 'smarty3') {
664 return $this->ldelim[$engine];
667 function get_template_rdelim($engine = 'smarty3') {
668 return $this->rdelim[$engine];
671 function save_timestamp($stamp, $value) {
672 if (!isset($this->config['system']['profiler']) || !$this->config['system']['profiler']) {
676 $duration = (float) (microtime(true) - $stamp);
678 if (!isset($this->performance[$value])) {
679 // Prevent ugly E_NOTICE
680 $this->performance[$value] = 0;
683 $this->performance[$value] += (float) $duration;
684 $this->performance['marktime'] += (float) $duration;
686 $callstack = System::callstack();
688 if (!isset($this->callstack[$value][$callstack])) {
689 // Prevent ugly E_NOTICE
690 $this->callstack[$value][$callstack] = 0;
693 $this->callstack[$value][$callstack] += (float) $duration;
697 * @brief Log active processes into the "process" table
699 function start_process() {
700 $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);
702 $command = basename($trace[0]['file']);
704 $this->remove_inactive_processes();
708 $r = q('SELECT `pid` FROM `process` WHERE `pid` = %d', intval(getmypid()));
709 if (!DBM::is_result($r)) {
710 dba::insert('process', array('pid' => getmypid(), 'command' => $command, 'created' => datetime_convert()));
716 * @brief Remove inactive processes
718 function remove_inactive_processes() {
721 $r = q('SELECT `pid` FROM `process`');
722 if (DBM::is_result($r)) {
723 foreach ($r AS $process) {
724 if (!posix_kill($process['pid'], 0)) {
725 dba::delete('process', array('pid' => $process['pid']));
733 * @brief Remove the active process from the "process" table
735 function end_process() {
736 dba::delete('process', array('pid' => getmypid()));
739 function get_useragent() {
741 FRIENDICA_PLATFORM . " '" .
742 FRIENDICA_CODENAME . "' " .
743 FRIENDICA_VERSION . '-' .
744 DB_UPDATE_VERSION . '; ' .
745 $this->get_baseurl();
748 function is_friendica_app() {
749 return $this->is_friendica_app;
753 * @brief Checks if the site is called via a backend process
755 * This isn't a perfect solution. But we need this check very early.
756 * So we cannot wait until the modules are loaded.
758 * @return bool Is it a known backend?
760 function is_backend() {
761 static $backends = array();
762 $backends[] = '_well_known';
764 $backends[] = 'dfrn_notify';
765 $backends[] = 'fetch';
766 $backends[] = 'hcard';
767 $backends[] = 'hostxrd';
768 $backends[] = 'nodeinfo';
769 $backends[] = 'noscrape';
771 $backends[] = 'poco';
772 $backends[] = 'post';
773 $backends[] = 'proxy';
774 $backends[] = 'pubsub';
775 $backends[] = 'pubsubhubbub';
776 $backends[] = 'receive';
777 $backends[] = 'rsd_xml';
778 $backends[] = 'salmon';
779 $backends[] = 'statistics_json';
782 // Check if current module is in backend or backend flag is set
783 return (in_array($this->module, $backends) || $this->backend);
787 * @brief Checks if the maximum number of database processes is reached
789 * @return bool Is the limit reached?
791 function max_processes_reached() {
792 // Deactivated, needs more investigating if this check really makes sense
795 if ($this->is_backend()) {
796 $process = 'backend';
797 $max_processes = Config::get('system', 'max_processes_backend');
798 if (intval($max_processes) == 0) {
802 $process = 'frontend';
803 $max_processes = Config::get('system', 'max_processes_frontend');
804 if (intval($max_processes) == 0) {
809 $processlist = DBM::processlist();
810 if ($processlist['list'] != '') {
811 logger('Processcheck: Processes: ' . $processlist['amount'] . ' - Processlist: ' . $processlist['list'], LOGGER_DEBUG);
813 if ($processlist['amount'] > $max_processes) {
814 logger('Processcheck: Maximum number of processes for ' . $process . ' tasks (' . $max_processes . ') reached.', LOGGER_DEBUG);
822 * @brief Checks if the minimal memory is reached
824 * @return bool Is the memory limit reached?
826 public function min_memory_reached() {
827 $min_memory = Config::get('system', 'min_memory', 0);
828 if ($min_memory == 0) {
832 if (!is_readable('/proc/meminfo')) {
836 $memdata = explode("\n", file_get_contents('/proc/meminfo'));
839 foreach ($memdata as $line) {
840 list($key, $val) = explode(':', $line);
841 $meminfo[$key] = (int) trim(str_replace('kB', '', $val));
842 $meminfo[$key] = (int) ($meminfo[$key] / 1024);
845 if (!isset($meminfo['MemAvailable']) || ! isset($meminfo['MemFree'])) {
849 $free = $meminfo['MemAvailable'] + $meminfo['MemFree'];
851 $reached = ($free < $min_memory);
854 logger('Minimal memory reached: ' . $free . '/' . $meminfo['MemTotal'] . ' - limit ' . $min_memory, LOGGER_DEBUG);
861 * @brief Checks if the maximum load is reached
863 * @return bool Is the load reached?
865 function maxload_reached() {
867 if ($this->is_backend()) {
868 $process = 'backend';
869 $maxsysload = intval(Config::get('system', 'maxloadavg'));
870 if ($maxsysload < 1) {
874 $process = 'frontend';
875 $maxsysload = intval(Config::get('system', 'maxloadavg_frontend'));
876 if ($maxsysload < 1) {
881 $load = current_load();
883 if (intval($load) > $maxsysload) {
884 logger('system: load ' . $load . ' for ' . $process . ' tasks (' . $maxsysload . ') too high.');
891 function proc_run($args) {
893 if (!function_exists('proc_open')) {
897 // If the last worker fork was less than 2 seconds before then don't fork another one.
898 // This should prevent the forking of masses of workers.
899 $cachekey = 'app:proc_run:started';
900 $result = Cache::get($cachekey);
902 if (!is_null($result) && ( time() - $result) < 2) {
906 // Set the timestamp of the last proc_run
907 Cache::set($cachekey, time(), CACHE_MINUTE);
909 array_unshift($args, ((x($this->config, 'php_path')) && (strlen($this->config['php_path'])) ? $this->config['php_path'] : 'php'));
911 // add baseurl to args. cli scripts can't construct it
912 $args[] = $this->get_baseurl();
914 for ($x = 0; $x < count($args); $x ++) {
915 $args[$x] = escapeshellarg($args[$x]);
918 $cmdline = implode($args, ' ');
920 if ($this->min_memory_reached()) {
924 if (Config::get('system', 'proc_windows')) {
925 $resource = proc_open('cmd /c start /b ' . $cmdline, array(), $foo, $this->get_basepath());
927 $resource = proc_open($cmdline . ' &', array(), $foo, $this->get_basepath());
929 if (!is_resource($resource)) {
930 logger('We got no resource for command ' . $cmdline, LOGGER_DEBUG);
933 proc_close($resource);
937 * @brief Returns the system user that is executing the script
939 * This mostly returns something like "www-data".
941 * @return string system username
943 static function systemuser() {
944 if (!function_exists('posix_getpwuid') || ! function_exists('posix_geteuid')) {
948 $processUser = posix_getpwuid(posix_geteuid());
949 return $processUser['name'];
953 * @brief Checks if a given directory is usable for the system
955 * @return boolean the directory is usable
957 static function directory_usable($directory, $check_writable = true) {
958 if ($directory == '') {
959 logger('Directory is empty. This shouldn\'t happen.', LOGGER_DEBUG);
963 if (!file_exists($directory)) {
964 logger('Path "' . $directory . '" does not exist for user ' . self::systemuser(), LOGGER_DEBUG);
967 if (is_file($directory)) {
968 logger('Path "' . $directory . '" is a file for user ' . self::systemuser(), LOGGER_DEBUG);
971 if (!is_dir($directory)) {
972 logger('Path "' . $directory . '" is not a directory for user ' . self::systemuser(), LOGGER_DEBUG);
975 if ($check_writable && !is_writable($directory)) {
976 logger('Path "' . $directory . '" is not writable for user ' . self::systemuser(), LOGGER_DEBUG);