Merge remote-tracking branch 'upstream/develop' into 1508-poco-ostatus

This commit is contained in:
Michael Vogel 2015-08-24 18:16:14 +02:00
commit 9ae4528d8b
23 changed files with 530 additions and 358 deletions

View file

@ -819,7 +819,7 @@ function probe_url($url, $mode = PROBE_NORMAL, $level = 1) {
}
}
Cache::set("probe_url:".$mode.":".$url,serialize($result));
Cache::set("probe_url:".$mode.":".$url,serialize($result), CACHE_DAY);
return $result;
}

View file

@ -5,33 +5,25 @@
class Cache {
public static function get($key) {
/*if (function_exists("apc_fetch") AND function_exists("apc_exists"))
if (apc_exists($key))
return(apc_fetch($key));*/
$r = q("SELECT `v` FROM `cache` WHERE `k`='%s' limit 1",
dbesc($key)
);
if (count($r)) {
/*if (function_exists("apc_store"))
apc_store($key, $r[0]['v'], 600);*/
if (count($r))
return $r[0]['v'];
}
return null;
}
public static function set($key,$value) {
public static function set($key,$value, $duration = CACHE_MONTH) {
q("REPLACE INTO `cache` (`k`,`v`,`updated`) VALUES ('%s','%s','%s')",
q("REPLACE INTO `cache` (`k`,`v`,`expire_mode`,`updated`) VALUES ('%s','%s',%d,'%s')",
dbesc($key),
dbesc($value),
intval($duration),
dbesc(datetime_convert()));
/*if (function_exists("apc_store"))
apc_store($key, $value, 600);*/
}
@ -63,8 +55,17 @@
public static function clear(){
q("DELETE FROM `cache` WHERE `updated` < '%s'",
dbesc(datetime_convert('UTC','UTC',"now - 30 days")));
q("DELETE FROM `cache` WHERE `updated` < '%s' AND `expire_mode` = %d",
dbesc(datetime_convert('UTC','UTC',"now - 30 days")), intval(CACHE_MONTH));
q("DELETE FROM `cache` WHERE `updated` < '%s' AND `expire_mode` = %d",
dbesc(datetime_convert('UTC','UTC',"now - 7 days")), intval(CACHE_WEEK));
q("DELETE FROM `cache` WHERE `updated` < '%s' AND `expire_mode` = %d",
dbesc(datetime_convert('UTC','UTC',"now - 1 days")), intval(CACHE_DAY));
q("DELETE FROM `cache` WHERE `updated` < '%s' AND `expire_mode` = %d",
dbesc(datetime_convert('UTC','UTC',"now - 1 hours")), intval(CACHE_HOUR));
}
}

View file

@ -364,6 +364,7 @@ function db_definition() {
"fields" => array(
"k" => array("type" => "varchar(255)", "not null" => "1", "primary" => "1"),
"v" => array("type" => "text", "not null" => "1"),
"expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
"updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
),
"indexes" => array(

View file

@ -183,7 +183,7 @@ function discover_directory($search) {
poco_check($data["url"], $data["name"], $data["network"], $data["photo"], "", "", "", $jj->tags, $data["addr"], "", 0);
}
}
Cache::set("dirsearch:".$search, time());
Cache::set("dirsearch:".$search, time(), CACHE_DAY);
}
if (array_search(__file__,get_included_files())===0){

View file

@ -969,7 +969,7 @@ function query_page_info($url, $no_photos = false, $photo = "", $keywords = fals
$data = Cache::get("parse_url:".$url);
if (is_null($data)){
$data = parseurl_getsiteinfo($url, true);
Cache::set("parse_url:".$url,serialize($data));
Cache::set("parse_url:".$url,serialize($data), CACHE_DAY);
} else
$data = unserialize($data);

View file

@ -26,7 +26,7 @@ function nav(&$a) {
$tpl = get_markup_template('nav.tpl');
$a->page['nav'] .= replace_macros($tpl, array(
'$baseurl' => $a->get_baseurl(),
'$baseurl' => $a->get_baseurl(),
'$langselector' => lang_selector(),
'$sitelocation' => $nav_info['sitelocation'],
'$nav' => $nav_info['nav'],
@ -118,6 +118,12 @@ function nav_info(&$a) {
$nav['search'] = array('search', t('Search'), "", t('Search site content'));
$nav['searchoption'] = array(
t("Full Text"),
t("Tags"),
t("Contacts"),
t("Forums"));
$gdirpath = 'directory';
if(strlen(get_config('system','singleuser'))) {

View file

@ -73,7 +73,7 @@ function oembed_fetch_url($embedurl, $no_rich_type = false){
if ($txt[0]!="{") $txt='{"type":"error"}';
//save in cache
Cache::set($a->videowidth . $embedurl,$txt);
Cache::set($a->videowidth . $embedurl,$txt, CACHE_DAY);
}

View file

@ -986,16 +986,26 @@ if(! function_exists('search')) {
* @param string $url search url
* @param boolean $savedsearch show save search button
*/
function search($s,$id='search-box',$url='/search',$save = false) {
function search($s,$id='search-box',$url='/search',$save = false, $aside = true) {
$a = get_app();
return replace_macros(get_markup_template('searchbox.tpl'), array(
'$s' => $s,
'$id' => $id,
'$action_url' => $a->get_baseurl((stristr($url,'network')) ? true : false) . $url,
'$search_label' => t('Search'),
'$save_label' => t('Save'),
'$savedsearch' => feature_enabled(local_user(),'savedsearch'),
));
$values = array(
'$s' => $s,
'$id' => $id,
'$action_url' => $a->get_baseurl((stristr($url,'network')) ? true : false) . $url,
'$search_label' => t('Search'),
'$save_label' => t('Save'),
'$savedsearch' => feature_enabled(local_user(),'savedsearch'),
);
if (!$aside)
$values['$searchoption'] = array(
t("Full Text"),
t("Tags"),
t("Contacts"),
t("Forums"));
return replace_macros(get_markup_template('searchbox.tpl'), $values);
}}
if(! function_exists('valid_email')) {