}
function get_cachefile($file, $writemode = true) {
- $cache = get_config("system","itemcache");
+ $cache = get_itemcachepath();
if ((! $cache) || (! is_dir($cache)))
return("");
function clear_cache($basepath = "", $path = "") {
if ($path == "") {
- $basepath = get_config('system','itemcache');
+ $basepath = get_itemcachepath();
$path = $basepath;
}
}
}
+function get_itemcachepath() {
+ // Checking, if the cache is deactivated
+ $cachetime = (int)get_config('system','itemcache_duration');
+ if ($cachetime < 0)
+ return "";
+
+ $itemcache = get_config('system','itemcache');
+ if (($itemcache != "") AND is_dir($itemcache) AND is_writable($itemcache))
+ return($itemcache);
+
+ $temppath = get_temppath();
+
+ if ($temppath != "") {
+ $itemcache = $temppath."/itemcache";
+ mkdir($itemcache);
+
+ if (is_dir($itemcache) AND is_writable($itemcache)) {
+ set_config("system", "itemcache", $itemcache);
+ return($itemcache);
+ }
+ }
+ return "";
+}
+
+function get_lockpath() {
+ $lockpath = get_config('system','lockpath');
+ if (($lockpath != "") AND is_dir($lockpath) AND is_writable($lockpath))
+ return($lockpath);
+
+ $temppath = get_temppath();
+
+ if ($temppath != "") {
+ $lockpath = $temppath."/lock";
+ mkdir($lockpath);
+
+ if (is_dir($lockpath) AND is_writable($lockpath)) {
+ set_config("system", "lockpath", $lockpath);
+ return($lockpath);
+ }
+ }
+ return "";
+}
+
+function get_temppath() {
+ $temppath = get_config("system","temppath");
+ if (($temppath != "") AND is_dir($temppath) AND is_writable($temppath))
+ return($temppath);
+
+ $temppath = sys_get_temp_dir();
+ if (($temppath != "") AND is_dir($temppath) AND is_writable($temppath)) {
+ set_config("system", "temppath", $temppath);
+ return($temppath);
+ }
+
+ return("");
+}
+
function set_template_engine(&$a, $engine = 'internal') {
// This function is no longer necessary, but keep it as a wrapper to the class method
// to avoid breaking themes again unnecessarily
if (is_null($data)) {
$img_str = fetch_url($url, true, $redirects, 4);
- $tempfile = tempnam(get_config("system","temppath"), "cache");
+ $tempfile = tempnam(get_temppath(), "cache");
file_put_contents($tempfile, $img_str);
$data = getimagesize($tempfile);
unlink($tempfile);
$posted = "";
- $itemcache = get_config("system","itemcache");
+ $itemcache = get_itemcachepath();
// relative dates only make sense when they aren't cached
if ($itemcache == "") {
$posted = "";
- $itemcache = get_config("system","itemcache");
+ $itemcache = get_itemcachepath();
// relative dates only make sense when they aren't cached
if ($itemcache == "") {
// removing multiplicated newlines
if (get_config("system", "remove_multiplicated_lines")) {
- $search = array("\n\n\n", "\n ", " \n", "[/quote]\n\n", "\n[/quote]", "[/li]\n", "\n[li]", "\n[ul]", "[/ul]\n");
- $replace = array("\n\n", "\n", "\n", "[/quote]\n", "[/quote]", "[/li]", "[li]", "[ul]", "[/ul]");
+ $search = array("\n\n\n", "\n ", " \n", "[/quote]\n\n", "\n[/quote]", "[/li]\n", "\n[li]", "\n[ul]", "[/ul]\n", "\n\n[share ");
+ $replace = array("\n\n", "\n", "\n", "[/quote]\n", "[/quote]", "[/li]", "[li]", "[ul]", "[/ul]", "\n[share ");
do {
$oldtext = $Text;
$Text = str_replace($search, $replace, $Text);
}
}
- $lockpath = get_config('system','lockpath');
+ $lockpath = get_lockpath();
if ($lockpath != '') {
$pidfile = new pidfile($lockpath, 'cronhooks');
if($pidfile->is_already_running()) {
}
// Test
- $lockpath = get_config('system','lockpath');
+ $lockpath = get_lockpath();
if ($lockpath != '') {
$pidfile = new pidfile($lockpath, 'onepoll'.$contact_id);
if($pidfile->is_already_running()) {
}
}
- $lockpath = get_config('system','lockpath');
+ $lockpath = get_lockpath();
if ($lockpath != '') {
$pidfile = new pidfile($lockpath, 'poller');
if($pidfile->is_already_running()) {
load_config('config');
load_config('system');
- $lockpath = get_config('system','lockpath');
+ $lockpath = get_lockpath();
if ($lockpath != '') {
$pidfile = new pidfile($lockpath, 'queue');
if($pidfile->is_already_running()) {
/* Banner */
$banner = get_config('system','banner');
- if($banner == false)
+ if($banner == false)
$banner = '<a href="http://friendica.com"><img id="logo-img" src="images/friendica-32.png" alt="logo" /></a><span id="logo-text"><a href="http://friendica.com">Friendica</a></span>';
$banner = htmlspecialchars($banner);
$info = get_config('config','info');
$info = htmlspecialchars($info);
+ // Automatically create temporary paths
+ get_temppath();
+ get_lockpath();
+ get_itemcachepath();
+
//echo "<pre>"; var_dump($lang_choices); die("</pre>");
/* Register policy */
'$use_fulltext_engine' => array('use_fulltext_engine', t("Use MySQL full text engine"), get_config('system','use_fulltext_engine'), t("Activates the full text engine. Speeds up search - but can only search for four and more characters.")),
'$suppress_language' => array('suppress_language', t("Suppress Language"), get_config('system','suppress_language'), t("Suppress language information in meta information about a posting.")),
'$itemcache' => array('itemcache', t("Path to item cache"), get_config('system','itemcache'), "The item caches buffers generated bbcode and external images."),
- '$itemcache_duration' => array('itemcache_duration', t("Cache duration in seconds"), get_config('system','itemcache_duration'), t("How long should the cache files be hold? Default value is 86400 seconds (One day).")),
+ '$itemcache_duration' => array('itemcache_duration', t("Cache duration in seconds"), get_config('system','itemcache_duration'), t("How long should the cache files be hold? Default value is 86400 seconds (One day). To disable the item cache, set the value to -1.")),
'$max_comments' => array('max_comments', t("Maximum numbers of comments per post"), get_config('system','max_comments'), t("How much comments should be shown for each post? Default value is 100.")),
'$lockpath' => array('lockpath', t("Path for lock file"), get_config('system','lockpath'), "The lock file is used to avoid multiple pollers at one time. Only define a folder here."),
'$temppath' => array('temppath', t("Temp path"), get_config('system','temppath'), "If you have a restricted system where the webserver can't access the system temp path, enter another path here."),