Merge pull request #1033 from annando/master

Temporary paths are now defined automatically
This commit is contained in:
Tobias Diekershoff 2014-06-24 06:29:35 +02:00
commit 3600ab1ffc
14 changed files with 653 additions and 485 deletions

View file

@ -693,6 +693,14 @@ if(! class_exists('App')) {
else else
$stylesheet = '$stylesheet'; $stylesheet = '$stylesheet';
$shortcut_icon = get_config("system", "shortcut_icon");
if ($shortcut_icon == "")
$shortcut_icon = $this->get_baseurl()."/images/friendica-32.png";
$touch_icon = get_config("system", "touch_icon");
if ($touch_icon == "")
$touch_icon = $this->get_baseurl()."/images/friendica-128.png";
$tpl = get_markup_template('head.tpl'); $tpl = get_markup_template('head.tpl');
$this->page['htmlhead'] = replace_macros($tpl,array( $this->page['htmlhead'] = replace_macros($tpl,array(
'$baseurl' => $this->get_baseurl(), // FIXME for z_path!!!! '$baseurl' => $this->get_baseurl(), // FIXME for z_path!!!!
@ -703,6 +711,8 @@ if(! class_exists('App')) {
'$showmore' => t('show more'), '$showmore' => t('show more'),
'$showfewer' => t('show fewer'), '$showfewer' => t('show fewer'),
'$update_interval' => $interval, '$update_interval' => $interval,
'$shortcut_icon' => $shortcut_icon,
'$touch_icon' => $touch_icon,
'$stylesheet' => $stylesheet '$stylesheet' => $stylesheet
)) . $this->page['htmlhead']; )) . $this->page['htmlhead'];
} }
@ -2150,7 +2160,7 @@ function random_digits($digits) {
} }
function get_cachefile($file, $writemode = true) { function get_cachefile($file, $writemode = true) {
$cache = get_config("system","itemcache"); $cache = get_itemcachepath();
if ((! $cache) || (! is_dir($cache))) if ((! $cache) || (! is_dir($cache)))
return(""); return("");
@ -2171,7 +2181,7 @@ function get_cachefile($file, $writemode = true) {
function clear_cache($basepath = "", $path = "") { function clear_cache($basepath = "", $path = "") {
if ($path == "") { if ($path == "") {
$basepath = get_config('system','itemcache'); $basepath = get_itemcachepath();
$path = $basepath; $path = $basepath;
} }
@ -2199,6 +2209,63 @@ function clear_cache($basepath = "", $path = "") {
} }
} }
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') { function set_template_engine(&$a, $engine = 'internal') {
// This function is no longer necessary, but keep it as a wrapper to the class method // This function is no longer necessary, but keep it as a wrapper to the class method
// to avoid breaking themes again unnecessarily // to avoid breaking themes again unnecessarily

File diff suppressed because it is too large Load diff

View file

@ -710,6 +710,8 @@
if($parent) if($parent)
$_REQUEST['type'] = 'net-comment'; $_REQUEST['type'] = 'net-comment';
else { else {
// logger("api_statuses_update: upload ".print_r($_FILES, true)." ".print_r($_POST, true)." ".print_r($_GET, true), LOGGER_DEBUG);
//die("blubb");
$_REQUEST['type'] = 'wall'; $_REQUEST['type'] = 'wall';
if(x($_FILES,'media')) { if(x($_FILES,'media')) {
// upload the image if we have one // upload the image if we have one
@ -1617,18 +1619,32 @@
return $ret; return $ret;
} }
function api_get_entitities($text, $bbcode) { function api_get_entitities(&$text, $bbcode) {
/* /*
To-Do: To-Do:
* Links at the first character of the post * Links at the first character of the post
* different sizes of pictures
* caching picture data (using the id for that?) (See privacy_image_cache)
*/ */
$a = get_app();
$result = q("SELECT `installed` FROM `addon` WHERE `name` = 'privacy_image_cache' AND `installed`");
$image_cache = (count($result) > 0);
$include_entities = strtolower(x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:"false"); $include_entities = strtolower(x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:"false");
if ($include_entities != "true") if ($include_entities != "true") {
if ($image_cache) {
require_once("addon/privacy_image_cache/privacy_image_cache.php");
preg_match_all("/\[img](.*?)\[\/img\]/ism", $bbcode, $images);
foreach ($images[1] AS $image) {
$replace = $a->get_baseurl()."/privacy_image_cache/".privacy_image_cache_cachename($image);
$text = str_replace($image, $replace, $text);
}
}
return array(); return array();
}
$bbcode = bb_CleanPictureLinks($bbcode); $bbcode = bb_CleanPictureLinks($bbcode);
@ -1717,24 +1733,47 @@
$start = iconv_strpos($text, $url, $offset, "UTF-8"); $start = iconv_strpos($text, $url, $offset, "UTF-8");
if (!($start === false)) { if (!($start === false)) {
$redirects = 0; require_once("include/Photo.php");
$img_str = fetch_url($url,true, $redirects, 10); $image = get_photo_info($url);
$image = @imagecreatefromstring($img_str);
if ($image) { if ($image) {
// If privacy_image_cache is activated, then use the following sizes:
// thumb (150), small (340), medium (600) and large (1024)
if ($image_cache) {
require_once("addon/privacy_image_cache/privacy_image_cache.php");
$media_url = $a->get_baseurl()."/privacy_image_cache/".privacy_image_cache_cachename($url);
$sizes = array();
$scale = scale_image($image[0], $image[1], 150);
$sizes["thumb"] = array("w" => $scale["width"], "h" => $scale["height"], "resize" => "fit");
if (($image[0] > 150) OR ($image[1] > 150)) {
$scale = scale_image($image[0], $image[1], 340);
$sizes["small"] = array("w" => $scale["width"], "h" => $scale["height"], "resize" => "fit");
}
$scale = scale_image($image[0], $image[1], 600);
$sizes["medium"] = array("w" => $scale["width"], "h" => $scale["height"], "resize" => "fit");
if (($image[0] > 600) OR ($image[1] > 600)) {
$scale = scale_image($image[0], $image[1], 1024);
$sizes["large"] = array("w" => $scale["width"], "h" => $scale["height"], "resize" => "fit");
}
} else {
$media_url = $url;
$sizes["medium"] = array("w" => $image[0], "h" => $image[1], "resize" => "fit");
}
$entities["media"][] = array( $entities["media"][] = array(
"id" => $start+1, "id" => $start+1,
"id_str" => (string)$start+1, "id_str" => (string)$start+1,
"indices" => array($start, $start+strlen($url)), "indices" => array($start, $start+strlen($url)),
"media_url" => $url, "media_url" => normalise_link($media_url),
"media_url_https" => $url, "media_url_https" => $media_url,
"url" => $url, "url" => $url,
"display_url" => $display_url, "display_url" => $display_url,
"expanded_url" => $url, "expanded_url" => $url,
"type" => "photo", "type" => "photo",
"sizes" => array("medium" => array( "sizes" => $sizes);
"w" => imagesx($image),
"h" => imagesy($image),
"resize" => "fit")));
} }
$offset = $start + 1; $offset = $start + 1;
} }

View file

@ -78,7 +78,7 @@ function bb2diaspora($Text,$preserve_nl = false, $fordiaspora = true) {
else { else {
$Text = bbcode($Text, $preserve_nl, false, 4); $Text = bbcode($Text, $preserve_nl, false, 4);
// Libertree doesn't convert a harizontal rule if there isn't a linefeed // Libertree doesn't convert a harizontal rule if there isn't a linefeed
$Text = str_replace("<hr />", "\n<hr />", $Text); $Text = str_replace("<hr />", "<br /><hr />", $Text);
} }
// Now convert HTML to Markdown // Now convert HTML to Markdown

View file

@ -424,7 +424,7 @@ function bb_ShareAttributes($match) {
$posted = ""; $posted = "";
$itemcache = get_config("system","itemcache"); $itemcache = get_itemcachepath();
// relative dates only make sense when they aren't cached // relative dates only make sense when they aren't cached
if ($itemcache == "") { if ($itemcache == "") {
@ -661,7 +661,7 @@ function bb_ShareAttributes($share, $simplehtml) {
$posted = ""; $posted = "";
$itemcache = get_config("system","itemcache"); $itemcache = get_itemcachepath();
// relative dates only make sense when they aren't cached // relative dates only make sense when they aren't cached
if ($itemcache == "") { if ($itemcache == "") {
@ -949,8 +949,8 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
// removing multiplicated newlines // removing multiplicated newlines
if (get_config("system", "remove_multiplicated_lines")) { 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"); $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]"); $replace = array("\n\n", "\n", "\n", "[/quote]\n", "[/quote]", "[/li]", "[li]", "[ul]", "[/ul]", "\n[share ");
do { do {
$oldtext = $Text; $oldtext = $Text;
$Text = str_replace($search, $replace, $Text); $Text = str_replace($search, $replace, $Text);

View file

@ -35,7 +35,7 @@ function cronhooks_run(&$argv, &$argc){
} }
} }
$lockpath = get_config('system','lockpath'); $lockpath = get_lockpath();
if ($lockpath != '') { if ($lockpath != '') {
$pidfile = new pidfile($lockpath, 'cronhooks'); $pidfile = new pidfile($lockpath, 'cronhooks');
if($pidfile->is_already_running()) { if($pidfile->is_already_running()) {

View file

@ -354,7 +354,7 @@ function db_definition() {
), ),
"indexes" => array( "indexes" => array(
"PRIMARY" => array("id"), "PRIMARY" => array("id"),
"access" => array("cat","k"), "access" => array("cat(30)","k(30)"),
) )
); );
$database["contact"] = array( $database["contact"] = array(
@ -638,7 +638,7 @@ function db_definition() {
), ),
"indexes" => array( "indexes" => array(
"PRIMARY" => array("id"), "PRIMARY" => array("id"),
"hook_file_function" => array("hook","file","function"), "hook_file_function" => array("hook(30)","file(60)","function(30)"),
) )
); );
$database["intro"] = array( $database["intro"] = array(
@ -890,7 +890,7 @@ function db_definition() {
), ),
"indexes" => array( "indexes" => array(
"PRIMARY" => array("id"), "PRIMARY" => array("id"),
"access" => array("uid","cat","k"), "access" => array("uid","cat(30)","k(30)"),
) )
); );
$database["photo"] = array( $database["photo"] = array(

View file

@ -58,7 +58,7 @@ function onepoll_run(&$argv, &$argc){
} }
// Test // Test
$lockpath = get_config('system','lockpath'); $lockpath = get_lockpath();
if ($lockpath != '') { if ($lockpath != '') {
$pidfile = new pidfile($lockpath, 'onepoll'.$contact_id); $pidfile = new pidfile($lockpath, 'onepoll'.$contact_id);
if($pidfile->is_already_running()) { if($pidfile->is_already_running()) {

View file

@ -41,7 +41,7 @@ function poller_run(&$argv, &$argc){
} }
} }
$lockpath = get_config('system','lockpath'); $lockpath = get_lockpath();
if ($lockpath != '') { if ($lockpath != '') {
$pidfile = new pidfile($lockpath, 'poller'); $pidfile = new pidfile($lockpath, 'poller');
if($pidfile->is_already_running()) { if($pidfile->is_already_running()) {

View file

@ -84,7 +84,7 @@ function queue_run(&$argv, &$argc){
load_config('config'); load_config('config');
load_config('system'); load_config('system');
$lockpath = get_config('system','lockpath'); $lockpath = get_lockpath();
if ($lockpath != '') { if ($lockpath != '') {
$pidfile = new pidfile($lockpath, 'queue'); $pidfile = new pidfile($lockpath, 'queue');
if($pidfile->is_already_running()) { if($pidfile->is_already_running()) {

View file

@ -548,12 +548,17 @@ function admin_page_site(&$a) {
/* Banner */ /* Banner */
$banner = get_config('system','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 = '<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); $banner = htmlspecialchars($banner);
$info = get_config('config','info'); $info = get_config('config','info');
$info = htmlspecialchars($info); $info = htmlspecialchars($info);
// Automatically create temporary paths
get_temppath();
get_lockpath();
get_itemcachepath();
//echo "<pre>"; var_dump($lang_choices); die("</pre>"); //echo "<pre>"; var_dump($lang_choices); die("</pre>");
/* Register policy */ /* Register policy */
@ -631,7 +636,7 @@ function admin_page_site(&$a) {
'$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.")), '$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.")), '$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' => 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.")), '$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."), '$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."), '$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."),

View file

@ -13,9 +13,13 @@
<link rel="stylesheet" type="text/css" href="{{$stylesheet}}" media="all" /> <link rel="stylesheet" type="text/css" href="{{$stylesheet}}" media="all" />
<!--
<link rel="shortcut icon" href="{{$baseurl}}/images/friendica-32.png" /> <link rel="shortcut icon" href="{{$baseurl}}/images/friendica-32.png" />
<link rel="apple-touch-icon" href="{{$baseurl}}/images/friendica-128.png"/> <link rel="apple-touch-icon" href="{{$baseurl}}/images/friendica-128.png"/>
-->
<link rel="shortcut icon" href="{{$shortcut_icon}}" />
<link rel="apple-touch-icon" href="{{$touch_icon}}"/>
<meta name="apple-mobile-web-app-capable" content="yes" /> <meta name="apple-mobile-web-app-capable" content="yes" />

View file

@ -19,6 +19,10 @@ img {
/* width: 80%;*/ /* width: 80%;*/
} }
#adminpage .screenshot img {
width: 640px;
}
#pending-update { #pending-update {
float:right; float:right;
color: #ffffff; color: #ffffff;

View file

@ -1,11 +1,11 @@
<?php <?php
/** /**
* Name: Vier * Name: Vier
* Version: 0.9 * Version: 1.1
* Author: Fabio <http://kirgroup.com/profile/fabrixxm> * Author: Fabio <http://kirgroup.com/profile/fabrixxm>
* Author: Ike <http://pirati.ca/profile/heluecht> * Author: Ike <http://pirati.ca/profile/heluecht>
* Maintainer: Ike <http://pirati.ca/profile/heluecht> * Maintainer: Ike <http://pirati.ca/profile/heluecht>
* Description: "Vier" uses the font awesome font library: http://fortawesome.github.com/Font-Awesome/ * Description: "Vier" is a very compact and modern theme. It uses the font awesome font library: http://fortawesome.github.com/Font-Awesome/
*/ */
function vier_init(&$a) { function vier_init(&$a) {