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;
49 public $data = array();
50 public $error = false;
61 public $interactive = true;
63 public $plugins_admin = array();
64 public $apps = array();
66 public $is_mobile = false;
67 public $is_tablet = false;
68 public $is_friendica_app;
69 public $performance = array();
70 public $callstack = array();
71 public $theme_info = array();
72 public $backend = true;
75 // Allow themes to control internal parameters
76 // by changing App values in theme.php
78 public $sourcename = '';
79 public $videowidth = 425;
80 public $videoheight = 350;
81 public $force_max_items = 0;
82 public $theme_events_in_profile = true;
85 * @brief An array for all theme-controllable parameters
87 * Mostly unimplemented yet. Only options 'template_engine' and
90 public $theme = array(
94 'force_max_items' => 0,
96 'template_engine' => 'smarty3',
100 * @brief An array of registered template engines ('name'=>'class name')
102 public $template_engines = array();
105 * @brief An array of instanced template engines ('name'=>'instance')
107 public $template_engine_instance = array();
110 private $ldelim = array(
114 private $rdelim = array(
122 private $curl_content_type;
123 private $curl_headers;
124 private $cached_profile_image;
125 private $cached_profile_picdate;
129 * @brief App constructor.
131 * @param string $basepath Path to the app base folder
133 function __construct($basepath) {
135 global $default_timezone;
139 if (! static::directory_usable($basepath, false)) {
140 throw new Exception('Basepath ' . $basepath . ' isn\'t usable.');
143 $this->basepath = rtrim($basepath, DIRECTORY_SEPARATOR);
145 if (file_exists($this->basepath.DIRECTORY_SEPARATOR.'.htpreconfig.php')) {
146 include $this->basepath.DIRECTORY_SEPARATOR.'.htpreconfig.php';
149 $this->timezone = ((x($default_timezone)) ? $default_timezone : 'UTC');
151 date_default_timezone_set($this->timezone);
153 $this->performance['start'] = microtime(true);
154 $this->performance['database'] = 0;
155 $this->performance['database_write'] = 0;
156 $this->performance['network'] = 0;
157 $this->performance['file'] = 0;
158 $this->performance['rendering'] = 0;
159 $this->performance['parser'] = 0;
160 $this->performance['marktime'] = 0;
161 $this->performance['markstart'] = microtime(true);
163 $this->callstack['database'] = array();
164 $this->callstack['database_write'] = array();
165 $this->callstack['network'] = array();
166 $this->callstack['file'] = array();
167 $this->callstack['rendering'] = array();
168 $this->callstack['parser'] = array();
170 $this->config = array();
171 $this->page = array();
172 $this->pager = array();
174 $this->query_string = '';
176 $this->process_id = uniqid('log', true);
180 $this->scheme = 'http';
182 if ((x($_SERVER, 'HTTPS') && $_SERVER['HTTPS']) ||
183 (x($_SERVER, 'HTTP_FORWARDED') && preg_match('/proto=https/', $_SERVER['HTTP_FORWARDED'])) ||
184 (x($_SERVER, 'HTTP_X_FORWARDED_PROTO') && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') ||
185 (x($_SERVER, 'HTTP_X_FORWARDED_SSL') && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') ||
186 (x($_SERVER, 'FRONT_END_HTTPS') && $_SERVER['FRONT_END_HTTPS'] == 'on') ||
187 (x($_SERVER, 'SERVER_PORT') && (intval($_SERVER['SERVER_PORT']) == 443)) // XXX: reasonable assumption, but isn't this hardcoding too much?
189 $this->scheme = 'https';
192 if (x($_SERVER, 'SERVER_NAME')) {
193 $this->hostname = $_SERVER['SERVER_NAME'];
195 if (x($_SERVER, 'SERVER_PORT') && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) {
196 $this->hostname .= ':' . $_SERVER['SERVER_PORT'];
199 * Figure out if we are running at the top of a domain
200 * or in a sub-directory and adjust accordingly
203 /// @TODO This kind of escaping breaks syntax-highlightning on CoolEdit (Midnight Commander)
204 $path = trim(dirname($_SERVER['SCRIPT_NAME']), '/\\');
205 if (isset($path) && strlen($path) && ($path != $this->path)) {
210 if ($hostname != '') {
211 $this->hostname = $hostname;
215 get_include_path() . PATH_SEPARATOR
216 . $this->basepath . DIRECTORY_SEPARATOR . 'include' . PATH_SEPARATOR
217 . $this->basepath . DIRECTORY_SEPARATOR . 'library' . PATH_SEPARATOR
221 if (is_array($_SERVER['argv']) && $_SERVER['argc'] > 1 && substr(end($_SERVER['argv']), 0, 4) == 'http') {
222 $this->set_baseurl(array_pop($_SERVER['argv']));
226 if ((x($_SERVER, 'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'], 0, 9) === 'pagename=') {
227 $this->query_string = substr($_SERVER['QUERY_STRING'], 9);
229 // removing trailing / - maybe a nginx problem
230 $this->query_string = ltrim($this->query_string, '/');
231 } elseif ((x($_SERVER, 'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'], 0, 2) === 'q=') {
232 $this->query_string = substr($_SERVER['QUERY_STRING'], 2);
234 // removing trailing / - maybe a nginx problem
235 $this->query_string = ltrim($this->query_string, '/');
238 if (x($_GET, 'pagename')) {
239 $this->cmd = trim($_GET['pagename'], '/\\');
240 } elseif (x($_GET, 'q')) {
241 $this->cmd = trim($_GET['q'], '/\\');
245 $this->query_string = str_replace($this->cmd . '&', $this->cmd . '?', $this->query_string);
247 // unix style "homedir"
248 if (substr($this->cmd, 0, 1) === '~') {
249 $this->cmd = 'profile/' . substr($this->cmd, 1);
252 // Diaspora style profile url
253 if (substr($this->cmd, 0, 2) === 'u/') {
254 $this->cmd = 'profile/' . substr($this->cmd, 2);
258 * Break the URL path into C style argc/argv style arguments for our
259 * modules. Given "http://example.com/module/arg1/arg2", $this->argc
260 * will be 3 (integer) and $this->argv will contain:
266 * There will always be one argument. If provided a naked domain
267 * URL, $this->argv[0] is set to "home".
270 $this->argv = explode('/', $this->cmd);
271 $this->argc = count($this->argv);
272 if ((array_key_exists('0', $this->argv)) && strlen($this->argv[0])) {
273 $this->module = str_replace('.', '_', $this->argv[0]);
274 $this->module = str_replace('-', '_', $this->module);
277 $this->argv = array('home');
278 $this->module = 'home';
281 // See if there is any page number information, and initialise pagination
282 $this->pager['page'] = ((x($_GET, 'page') && intval($_GET['page']) > 0) ? intval($_GET['page']) : 1);
283 $this->pager['itemspage'] = 50;
284 $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];
286 if ($this->pager['start'] < 0) {
287 $this->pager['start'] = 0;
289 $this->pager['total'] = 0;
291 // Detect mobile devices
292 $mobile_detect = new MobileDetect();
293 $this->is_mobile = $mobile_detect->isMobile();
294 $this->is_tablet = $mobile_detect->isTablet();
297 $this->is_friendica_app = ($_SERVER['HTTP_USER_AGENT'] == 'Apache-HttpClient/UNAVAILABLE (java 1.4)');
299 // Register template engines
300 $dc = get_declared_classes();
301 foreach ($dc as $k) {
302 if (in_array('Friendica\Render\ITemplateEngine', class_implements($k))) {
303 $this->register_template_engine($k);
311 * @brief Returns the base filesystem path of the App
313 * It first checks for the internal variable, then for DOCUMENT_ROOT and
318 public function get_basepath() {
319 $basepath = $this->basepath;
322 $basepath = Config::get('system', 'basepath');
325 if (! $basepath && x($_SERVER, 'DOCUMENT_ROOT')) {
326 $basepath = $_SERVER['DOCUMENT_ROOT'];
329 if (! $basepath && x($_SERVER, 'PWD')) {
330 $basepath = $_SERVER['PWD'];
333 return self::realpath($basepath);
337 * @brief Returns a normalized file path
339 * This is a wrapper for the "realpath" function.
340 * That function cannot detect the real path when some folders aren't readable.
341 * Since this could happen with some hosters we need to handle this.
343 * @param string $path The path that is about to be normalized
344 * @return string normalized path - when possible
346 public static function realpath($path) {
347 $normalized = realpath($path);
349 if (!is_bool($normalized)) {
356 function get_scheme() {
357 return $this->scheme;
361 * @brief Retrieves the Friendica instance base URL
363 * This function assembles the base URL from multiple parts:
364 * - Protocol is determined either by the request or a combination of
365 * system.ssl_policy and the $ssl parameter.
366 * - Host name is determined either by system.hostname or inferred from request
367 * - Path is inferred from SCRIPT_NAME
369 * Note: $ssl parameter value doesn't directly correlate with the resulting protocol
371 * @param bool $ssl Whether to append http or https under SSL_POLICY_SELFSIGN
372 * @return string Friendica server base URL
374 function get_baseurl($ssl = false) {
375 $scheme = $this->scheme;
377 if (Config::get('system', 'ssl_policy') == SSL_POLICY_FULL) {
381 // Basically, we have $ssl = true on any links which can only be seen by a logged in user
382 // (and also the login link). Anything seen by an outsider will have it turned off.
384 if (Config::get('system', 'ssl_policy') == SSL_POLICY_SELFSIGN) {
392 if (Config::get('config', 'hostname') != '') {
393 $this->hostname = Config::get('config', 'hostname');
396 return $scheme . '://' . $this->hostname . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : '' );
400 * @brief Initializes the baseurl components
402 * Clears the baseurl cache to prevent inconstistencies
406 function set_baseurl($url) {
407 $parsed = @parse_url($url);
410 $this->scheme = $parsed['scheme'];
412 $hostname = $parsed['host'];
413 if (x($parsed, 'port')) {
414 $hostname .= ':' . $parsed['port'];
416 if (x($parsed, 'path')) {
417 $this->path = trim($parsed['path'], '\\/');
420 if (file_exists($this->basepath.DIRECTORY_SEPARATOR.'.htpreconfig.php')) {
421 include $this->basepath.DIRECTORY_SEPARATOR.'.htpreconfig.php';
424 if (Config::get('config', 'hostname') != '') {
425 $this->hostname = Config::get('config', 'hostname');
428 if (!isset($this->hostname) || ( $this->hostname == '')) {
429 $this->hostname = $hostname;
434 function get_hostname() {
435 if (Config::get('config', 'hostname') != '') {
436 $this->hostname = Config::get('config', 'hostname');
439 return $this->hostname;
442 function set_hostname($h) {
443 $this->hostname = $h;
446 function set_path($p) {
447 $this->path = trim(trim($p), '/');
450 function get_path() {
454 function set_pager_total($n) {
455 $this->pager['total'] = intval($n);
458 function set_pager_itemspage($n) {
459 $this->pager['itemspage'] = ((intval($n) > 0) ? intval($n) : 0);
460 $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];
463 function set_pager_page($n) {
464 $this->pager['page'] = $n;
465 $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];
468 function init_pagehead() {
469 $interval = ((local_user()) ? PConfig::get(local_user(), 'system', 'update_interval') : 40000);
471 // If the update is 'deactivated' set it to the highest integer number (~24 days)
473 $interval = 2147483647;
476 if ($interval < 10000) {
480 // compose the page title from the sitename and the
481 // current module called
482 if (!$this->module == '') {
483 $this->page['title'] = $this->config['sitename'] . ' (' . $this->module . ')';
485 $this->page['title'] = $this->config['sitename'];
488 /* put the head template at the beginning of page['htmlhead']
489 * since the code added by the modules frequently depends on it
492 if (!isset($this->page['htmlhead'])) {
493 $this->page['htmlhead'] = '';
496 // If we're using Smarty, then doing replace_macros() will replace
497 // any unrecognized variables with a blank string. Since we delay
498 // replacing $stylesheet until later, we need to replace it now
499 // with another variable name
500 if ($this->theme['template_engine'] === 'smarty3') {
501 $stylesheet = $this->get_template_ldelim('smarty3') . '$stylesheet' . $this->get_template_rdelim('smarty3');
503 $stylesheet = '$stylesheet';
506 $shortcut_icon = Config::get('system', 'shortcut_icon');
507 if ($shortcut_icon == '') {
508 $shortcut_icon = 'images/friendica-32.png';
511 $touch_icon = Config::get('system', 'touch_icon');
512 if ($touch_icon == '') {
513 $touch_icon = 'images/friendica-128.png';
516 // get data wich is needed for infinite scroll on the network page
517 $invinite_scroll = infinite_scroll_data($this->module);
519 $tpl = get_markup_template('head.tpl');
520 $this->page['htmlhead'] = replace_macros($tpl, array(
521 '$baseurl' => $this->get_baseurl(),
522 '$local_user' => local_user(),
523 '$generator' => 'Friendica' . ' ' . FRIENDICA_VERSION,
524 '$delitem' => t('Delete this item?'),
525 '$showmore' => t('show more'),
526 '$showfewer' => t('show fewer'),
527 '$update_interval' => $interval,
528 '$shortcut_icon' => $shortcut_icon,
529 '$touch_icon' => $touch_icon,
530 '$stylesheet' => $stylesheet,
531 '$infinite_scroll' => $invinite_scroll,
532 )) . $this->page['htmlhead'];
535 function init_page_end() {
536 if (!isset($this->page['end'])) {
537 $this->page['end'] = '';
539 $tpl = get_markup_template('end.tpl');
540 $this->page['end'] = replace_macros($tpl, array(
541 '$baseurl' => $this->get_baseurl()
542 )) . $this->page['end'];
545 function set_curl_code($code) {
546 $this->curl_code = $code;
549 function get_curl_code() {
550 return $this->curl_code;
553 function set_curl_content_type($content_type) {
554 $this->curl_content_type = $content_type;
557 function get_curl_content_type() {
558 return $this->curl_content_type;
561 function set_curl_headers($headers) {
562 $this->curl_headers = $headers;
565 function get_curl_headers() {
566 return $this->curl_headers;
569 function get_cached_avatar_image($avatar_image) {
570 return $avatar_image;
574 * @brief Removes the baseurl from an url. This avoids some mixed content problems.
576 * @param string $orig_url
578 * @return string The cleaned url
580 function remove_baseurl($orig_url) {
582 // Remove the hostname from the url if it is an internal link
583 $nurl = normalise_link($orig_url);
584 $base = normalise_link($this->get_baseurl());
585 $url = str_replace($base . '/', '', $nurl);
587 // if it is an external link return the orignal value
588 if ($url == normalise_link($orig_url)) {
596 * @brief Register template engine class
598 * If $name is '', is used class static property $class::$name
600 * @param string $class
601 * @param string $name
603 function register_template_engine($class, $name = '') {
604 /// @TODO Really === and not just == ?
606 $v = get_class_vars($class);
611 echo "template engine <tt>$class</tt> cannot be registered without a name.\n";
614 $this->template_engines[$name] = $class;
618 * @brief Return template engine instance.
620 * If $name is not defined, return engine defined by theme,
623 * @param string $name Template engine name
624 * @return object Template Engine instance
626 function template_engine($name = '') {
627 /// @TODO really type-check included?
629 $template_engine = $name;
631 $template_engine = 'smarty3';
632 if (x($this->theme, 'template_engine')) {
633 $template_engine = $this->theme['template_engine'];
637 if (isset($this->template_engines[$template_engine])) {
638 if (isset($this->template_engine_instance[$template_engine])) {
639 return $this->template_engine_instance[$template_engine];
641 $class = $this->template_engines[$template_engine];
643 $this->template_engine_instance[$template_engine] = $obj;
648 echo "template engine <tt>$template_engine</tt> is not registered!\n";
653 * @brief Returns the active template engine.
657 function get_template_engine() {
658 return $this->theme['template_engine'];
661 function set_template_engine($engine = 'smarty3') {
662 $this->theme['template_engine'] = $engine;
665 function get_template_ldelim($engine = 'smarty3') {
666 return $this->ldelim[$engine];
669 function get_template_rdelim($engine = 'smarty3') {
670 return $this->rdelim[$engine];
673 function save_timestamp($stamp, $value) {
674 if (!isset($this->config['system']['profiler']) || !$this->config['system']['profiler']) {
678 $duration = (float) (microtime(true) - $stamp);
680 if (!isset($this->performance[$value])) {
681 // Prevent ugly E_NOTICE
682 $this->performance[$value] = 0;
685 $this->performance[$value] += (float) $duration;
686 $this->performance['marktime'] += (float) $duration;
688 $callstack = System::callstack();
690 if (!isset($this->callstack[$value][$callstack])) {
691 // Prevent ugly E_NOTICE
692 $this->callstack[$value][$callstack] = 0;
695 $this->callstack[$value][$callstack] += (float) $duration;
699 * @brief Log active processes into the "process" table
701 function start_process() {
702 $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);
704 $command = basename($trace[0]['file']);
706 $this->remove_inactive_processes();
710 $r = q('SELECT `pid` FROM `process` WHERE `pid` = %d', intval(getmypid()));
711 if (!DBM::is_result($r)) {
712 dba::insert('process', array('pid' => getmypid(), 'command' => $command, 'created' => datetime_convert()));
718 * @brief Remove inactive processes
720 function remove_inactive_processes() {
723 $r = q('SELECT `pid` FROM `process`');
724 if (DBM::is_result($r)) {
725 foreach ($r AS $process) {
726 if (!posix_kill($process['pid'], 0)) {
727 dba::delete('process', array('pid' => $process['pid']));
735 * @brief Remove the active process from the "process" table
737 function end_process() {
738 dba::delete('process', array('pid' => getmypid()));
741 function get_useragent() {
743 FRIENDICA_PLATFORM . " '" .
744 FRIENDICA_CODENAME . "' " .
745 FRIENDICA_VERSION . '-' .
746 DB_UPDATE_VERSION . '; ' .
747 $this->get_baseurl();
750 function is_friendica_app() {
751 return $this->is_friendica_app;
755 * @brief Checks if the site is called via a backend process
757 * This isn't a perfect solution. But we need this check very early.
758 * So we cannot wait until the modules are loaded.
760 * @return bool Is it a known backend?
762 function is_backend() {
763 static $backends = array();
764 $backends[] = '_well_known';
766 $backends[] = 'dfrn_notify';
767 $backends[] = 'fetch';
768 $backends[] = 'hcard';
769 $backends[] = 'hostxrd';
770 $backends[] = 'nodeinfo';
771 $backends[] = 'noscrape';
773 $backends[] = 'poco';
774 $backends[] = 'post';
775 $backends[] = 'proxy';
776 $backends[] = 'pubsub';
777 $backends[] = 'pubsubhubbub';
778 $backends[] = 'receive';
779 $backends[] = 'rsd_xml';
780 $backends[] = 'salmon';
781 $backends[] = 'statistics_json';
784 // Check if current module is in backend or backend flag is set
785 return (in_array($this->module, $backends) || $this->backend);
789 * @brief Checks if the maximum number of database processes is reached
791 * @return bool Is the limit reached?
793 function max_processes_reached() {
794 // Deactivated, needs more investigating if this check really makes sense
797 if ($this->is_backend()) {
798 $process = 'backend';
799 $max_processes = Config::get('system', 'max_processes_backend');
800 if (intval($max_processes) == 0) {
804 $process = 'frontend';
805 $max_processes = Config::get('system', 'max_processes_frontend');
806 if (intval($max_processes) == 0) {
811 $processlist = DBM::processlist();
812 if ($processlist['list'] != '') {
813 logger('Processcheck: Processes: ' . $processlist['amount'] . ' - Processlist: ' . $processlist['list'], LOGGER_DEBUG);
815 if ($processlist['amount'] > $max_processes) {
816 logger('Processcheck: Maximum number of processes for ' . $process . ' tasks (' . $max_processes . ') reached.', LOGGER_DEBUG);
824 * @brief Checks if the minimal memory is reached
826 * @return bool Is the memory limit reached?
828 public function min_memory_reached() {
829 $min_memory = Config::get('system', 'min_memory', 0);
830 if ($min_memory == 0) {
834 if (!is_readable('/proc/meminfo')) {
838 $memdata = explode("\n", file_get_contents('/proc/meminfo'));
841 foreach ($memdata as $line) {
842 list($key, $val) = explode(':', $line);
843 $meminfo[$key] = (int) trim(str_replace('kB', '', $val));
844 $meminfo[$key] = (int) ($meminfo[$key] / 1024);
847 if (!isset($meminfo['MemAvailable']) || ! isset($meminfo['MemFree'])) {
851 $free = $meminfo['MemAvailable'] + $meminfo['MemFree'];
853 $reached = ($free < $min_memory);
856 logger('Minimal memory reached: ' . $free . '/' . $meminfo['MemTotal'] . ' - limit ' . $min_memory, LOGGER_DEBUG);
863 * @brief Checks if the maximum load is reached
865 * @return bool Is the load reached?
867 function maxload_reached() {
869 if ($this->is_backend()) {
870 $process = 'backend';
871 $maxsysload = intval(Config::get('system', 'maxloadavg'));
872 if ($maxsysload < 1) {
876 $process = 'frontend';
877 $maxsysload = intval(Config::get('system', 'maxloadavg_frontend'));
878 if ($maxsysload < 1) {
883 $load = current_load();
885 if (intval($load) > $maxsysload) {
886 logger('system: load ' . $load . ' for ' . $process . ' tasks (' . $maxsysload . ') too high.');
893 function proc_run($args) {
895 if (!function_exists('proc_open')) {
899 // If the last worker fork was less than 2 seconds before then don't fork another one.
900 // This should prevent the forking of masses of workers.
901 $cachekey = 'app:proc_run:started';
902 $result = Cache::get($cachekey);
904 if (!is_null($result) && ( time() - $result) < 2) {
908 // Set the timestamp of the last proc_run
909 Cache::set($cachekey, time(), CACHE_MINUTE);
911 array_unshift($args, ((x($this->config, 'php_path')) && (strlen($this->config['php_path'])) ? $this->config['php_path'] : 'php'));
913 // add baseurl to args. cli scripts can't construct it
914 $args[] = $this->get_baseurl();
916 for ($x = 0; $x < count($args); $x ++) {
917 $args[$x] = escapeshellarg($args[$x]);
920 $cmdline = implode($args, ' ');
922 if ($this->min_memory_reached()) {
926 if (Config::get('system', 'proc_windows')) {
927 $resource = proc_open('cmd /c start /b ' . $cmdline, array(), $foo, $this->get_basepath());
929 $resource = proc_open($cmdline . ' &', array(), $foo, $this->get_basepath());
931 if (!is_resource($resource)) {
932 logger('We got no resource for command ' . $cmdline, LOGGER_DEBUG);
935 proc_close($resource);
939 * @brief Returns the system user that is executing the script
941 * This mostly returns something like "www-data".
943 * @return string system username
945 static function systemuser() {
946 if (!function_exists('posix_getpwuid') || ! function_exists('posix_geteuid')) {
950 $processUser = posix_getpwuid(posix_geteuid());
951 return $processUser['name'];
955 * @brief Checks if a given directory is usable for the system
957 * @return boolean the directory is usable
959 static function directory_usable($directory, $check_writable = true) {
960 if ($directory == '') {
961 logger('Directory is empty. This shouldn\'t happen.', LOGGER_DEBUG);
965 if (!file_exists($directory)) {
966 logger('Path "' . $directory . '" does not exist for user ' . self::systemuser(), LOGGER_DEBUG);
969 if (is_file($directory)) {
970 logger('Path "' . $directory . '" is a file for user ' . self::systemuser(), LOGGER_DEBUG);
973 if (!is_dir($directory)) {
974 logger('Path "' . $directory . '" is not a directory for user ' . self::systemuser(), LOGGER_DEBUG);
977 if ($check_writable && !is_writable($directory)) {
978 logger('Path "' . $directory . '" is not writable for user ' . self::systemuser(), LOGGER_DEBUG);