ini_set('pcre.backtrack_limit', 250000);
-define ( 'FRIENDIKA_VERSION', '2.2.991' );
+define ( 'FRIENDIKA_VERSION', '2.2.1018' );
define ( 'DFRN_PROTOCOL_VERSION', '2.21' );
-define ( 'DB_UPDATE_VERSION', 1058 );
+define ( 'DB_UPDATE_VERSION', 1065 );
define ( 'EOL', "<br />\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
define ( 'NAMESPACE_GEORSS', 'http://www.georss.org/georss' );
define ( 'NAMESPACE_POCO', 'http://portablecontacts.net/spec/1.0' );
define ( 'NAMESPACE_FEED', 'http://schemas.google.com/g/2010#updates-from' );
+define ( 'NAMESPACE_OSTATUS', 'http://ostatus.org/schema/1.0' );
+define ( 'NAMESPACE_STATUSNET', 'http://status.net/schema/api/1/' );
/**
* activity stream defines
define ( 'ACTIVITY_OBJ_PHOTO', NAMESPACE_ACTIVITY_SCHEMA . 'photo' );
define ( 'ACTIVITY_OBJ_P_PHOTO', NAMESPACE_ACTIVITY_SCHEMA . 'profile-photo' );
define ( 'ACTIVITY_OBJ_ALBUM', NAMESPACE_ACTIVITY_SCHEMA . 'photo-album' );
+define ( 'ACTIVITY_OBJ_EVENT', NAMESPACE_ACTIVITY_SCHEMA . 'event' );
/**
* item weight for query ordering
killme();
}}
+
+// install and uninstall plugin
+if (! function_exists('uninstall_plugin')){
+function uninstall_plugin($plugin){
+ logger("Addons: uninstalling " . $plugin);
+ q("DELETE FROM `addon` WHERE `name` = '%s' LIMIT 1",
+ dbesc($plugin)
+ );
+
+ @include_once('addon/' . $plugin . '/' . $plugin . '.php');
+ if(function_exists($plugin . '_uninstall')) {
+ $func = $plugin . '_uninstall';
+ $func();
+ }
+}}
+
+if (! function_exists('install_plugin')){
+function install_plugin($plugin){
+ logger("Addons: installing " . $plugin);
+ $t = filemtime('addon/' . $plugin . '/' . $plugin . '.php');
+ @include_once('addon/' . $plugin . '/' . $plugin . '.php');
+ if(function_exists($plugin . '_install')) {
+ $func = $plugin . '_install';
+ $func();
+
+ $plugin_admin = (function_exists($plugin."_plugin_admin")?1:0);
+
+ $r = q("INSERT INTO `addon` (`name`, `installed`, `timestamp`, `plugin_admin`) VALUES ( '%s', 1, %d , %d ) ",
+ dbesc($plugin),
+ intval($t),
+ $plugin_admin
+ );
+ }
+}}
+
// Primarily involved with database upgrade, but also sets the
// base url for use in cmdline programs which don't have
// $_SERVER variables, and synchronising the state of installed plugins.
$stored = intval($build);
$current = intval(DB_UPDATE_VERSION);
if(($stored < $current) && file_exists('update.php')) {
+
// We're reporting a different version than what is currently installed.
// Run any existing update scripts to bring the database up to current.
require_once('update.php');
- for($x = $stored; $x < $current; $x ++) {
- if(function_exists('update_' . $x)) {
- $func = 'update_' . $x;
- $func($a);
+
+ // make sure that boot.php and update.php are the same release, we might be
+ // updating right this very second and the correct version of the update.php
+ // file may not be here yet. This can happen on a very busy site.
+
+ if(DB_UPDATE_VERSION == UPDATE_VERSION) {
+
+ for($x = $stored; $x < $current; $x ++) {
+ if(function_exists('update_' . $x)) {
+ $func = 'update_' . $x;
+ $func($a);
+ }
}
+ set_config('system','build', DB_UPDATE_VERSION);
}
- set_config('system','build', DB_UPDATE_VERSION);
}
}
if(count($installed)) {
foreach($installed as $i) {
if(! in_array($i['name'],$plugins_arr)) {
- logger("Addons: uninstalling " . $i['name']);
- q("DELETE FROM `addon` WHERE `id` = %d LIMIT 1",
- intval($i['id'])
- );
-
- @include_once('addon/' . $i['name'] . '/' . $i['name'] . '.php');
- if(function_exists($i['name'] . '_uninstall')) {
- $func = $i['name'] . '_uninstall';
- $func();
- }
+ uninstall_plugin($i['name']);
}
else
$installed_arr[] = $i['name'];
if(count($plugins_arr)) {
foreach($plugins_arr as $p) {
if(! in_array($p,$installed_arr)) {
- logger("Addons: installing " . $p);
- $t = filemtime('addon/' . $p . '/' . $p . '.php');
- @include_once('addon/' . $p . '/' . $p . '.php');
- if(function_exists($p . '_install')) {
- $func = $p . '_install';
- $func();
- $r = q("INSERT INTO `addon` (`name`, `installed`, `timestamp`) VALUES ( '%s', 1, %d ) ",
- dbesc($p),
- intval($t)
- );
- }
+ install_plugin($p);
}
}
}
$s = substr($s,strlen($header)+4);
$header = substr($s,0,strpos($s,"\r\n\r\n"));
}
- if($http_code == 301 || $http_code == 302 || $http_code == 303) {
+ if($http_code == 301 || $http_code == 302 || $http_code == 303 || $http_code == 307) {
$matches = array();
preg_match('/(Location:|URI:)(.*?)\n/', $header, $matches);
$url = trim(array_pop($matches));
dbesc($key)
);
if(count($ret)) {
- $a->config[$family][$key] = $ret[0]['v'];
- return $ret[0]['v'];
+ // manage array value
+ $val = (preg_match("|^a:[0-9]+:{.*}$|", $ret[0]['v'])?unserialize( $ret[0]['v']):$ret[0]['v']);
+ $a->config[$family][$key] = $val;
+ return $val;
}
else {
$a->config[$family][$key] = '!<unset>!';
if(! function_exists('set_config')) {
function set_config($family,$key,$value) {
-
global $a;
+
+ // manage array value
+ $dbvalue = (is_array($value)?serialize($value):$value);
if(get_config($family,$key,true) === false) {
$a->config[$family][$key] = $value;
$ret = q("INSERT INTO `config` ( `cat`, `k`, `v` ) VALUES ( '%s', '%s', '%s' ) ",
dbesc($family),
dbesc($key),
- dbesc($value)
+ dbesc($dbvalue)
);
if($ret)
return $value;
return $ret;
}
+
$ret = q("UPDATE `config` SET `v` = '%s' WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1",
- dbesc($value),
+ dbesc($dbvalue),
dbesc($family),
dbesc($key)
);
if(! function_exists('search')) {
-function search($s) {
+function search($s,$id='search-box',$url='/search') {
$a = get_app();
- $o = '<div id="search-box">';
- $o .= '<form action="' . $a->get_baseurl() . '/search' . '" method="get" >';
+ $o = '<div id="' . $id . '">';
+ $o .= '<form action="' . $a->get_baseurl() . $url . '" method="get" >';
$o .= '<input type="text" name="search" id="search-text" value="' . $s .'" />';
$o .= '<input type="submit" name="submit" id="search-submit" value="' . t('Search') . '" />';
$o .= '</form></div>';
$a = get_app();
return str_replace(
- array( '<3', '</3', '<\\3', ':-)', ';-)', ':-(', ':(', ':-P', ':P', ':-"', ':-x', ':-X', ':-D', '8-|', '8-O'),
+ array( '<3', '</3', '<\\3', ':-)', ':)', ';-)', ':-(', ':(', ':-P', ':P', ':-"', ':-x', ':-X', ':-D', '8-|', '8-O'),
array(
'<img src="' . $a->get_baseurl() . '/images/smiley-heart.gif" alt="<3" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-brokenheart.gif" alt="</3" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-brokenheart.gif" alt="<\\3" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-smile.gif" alt=":-)" />',
+ '<img src="' . $a->get_baseurl() . '/images/smiley-smile.gif" alt=":)" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-wink.gif" alt=";-)" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-frown.gif" alt=":-(" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-frown.gif" alt=":(" />',
return $s;
$arr = explode(',',$item['attach']);
- $s .= '<div class="body-attach">';
if(count($arr)) {
+ $s .= '<div class="body-attach">';
foreach($arr as $r) {
$matches = false;
$icon = '';
- $cnt = preg_match('|\[attach\]href=\"(.+?)\" size=\"(.+?)\" type=\"(.+?)\" title=\"(.+?)\"\[\/attach\]|',$r,$matches);
+ $cnt = preg_match('|\[attach\]href=\"(.*?)\" size=\"(.*?)\" type=\"(.*?)\" title=\"(.*?)\"\[\/attach\]|',$r,$matches);
if($cnt) {
$icontype = strtolower(substr($matches[3],0,strpos($matches[3],'/')));
switch($icontype) {
$s .= '<a href="' . strip_tags($matches[1]) . '" title="' . $title . '" class="attachlink" target="external-link" >' . $icon . '</a>';
}
}
+ $s .= '<div class="clear"></div></div>';
}
- $s .= '<div class="clear"></div></div>';
return $s;
}}
if(! function_exists('lang_selector')) {
function lang_selector() {
global $lang;
+ $o = '<div id="lang-select-icon" class="icon language" title="' . t('Select an alternate language') . '" onclick="openClose(\'language-selector\');" ></div>';
$o .= '<div id="language-selector" style="display: none;" >';
$o .= '<form action="" method="post" ><select name="system_language" onchange="this.form.submit();" >';
$langs = glob('view/*/strings.php');
if(is_array($langs) && count($langs)) {
if(! in_array('view/en/strings.php',$langs))
$langs[] = 'view/en/';
+ asort($langs);
foreach($langs as $l) {
$ll = substr($l,5);
$ll = substr($ll,0,strrpos($ll,'/'));
if(! function_exists('parse_xml_string')) {
-function parse_xml_string($s) {
- if(! strstr($s,'<?xml'))
- return false;
- $s2 = substr($s,strpos($s,'<?xml'));
+function parse_xml_string($s,$strict = true) {
+ if($strict) {
+ if(! strstr($s,'<?xml'))
+ return false;
+ $s2 = substr($s,strpos($s,'<?xml'));
+ }
+ else
+ $s2 = $s;
libxml_use_internal_errors(true);
+
$x = @simplexml_load_string($s2);
- if(count(libxml_get_errors()))
+ if(! $x) {
+ logger('libxml: parse: error: ' . $s2, LOGGER_DATA);
foreach(libxml_get_errors() as $err)
logger('libxml: parse: ' . $err->code." at ".$err->line.":".$err->column." : ".$err->message, LOGGER_DATA);
- libxml_clear_errors();
+ libxml_clear_errors();
+ }
return $x;
}}
return false;
}}
+/*
+ * parse plugin comment in search of plugin infos.
+ * like
+ *
+ * * Name: Plugin
+ * * Description: A plugin which plugs in
+ * * Version: 1.2.3
+ * * Author: John <profile url>
+ * * Author: Jane <email>
+ * *
+ */
+
+if (! function_exists('get_plugin_info')){
+function get_plugin_info($plugin){
+ if (!is_file("addon/$plugin/$plugin.php")) return false;
+
+ $f = file_get_contents("addon/$plugin/$plugin.php");
+ $r = preg_match("|/\*.*\*/|msU", $f, $m);
+
+ $info=Array(
+ 'name' => $plugin,
+ 'description' => "",
+ 'author' => array(),
+ 'version' => ""
+ );
+
+ if ($r){
+ $ll = explode("\n", $m[0]);
+ foreach( $ll as $l ) {
+ $l = trim($l,"\t\n\r */");
+ if ($l!=""){
+ list($k,$v) = array_map("trim", explode(":",$l,2));
+ $k= strtolower($k);
+ if ($k=="author"){
+ $r=preg_match("|([^<]+)<([^>]+)>|", $v, $m);
+ if ($r) {
+ $info['author'][] = array('name'=>$m[1], 'link'=>$m[2]);
+ } else {
+ $info['author'][] = array('name'=>$v);
+ }
+ } else {
+ if (array_key_exists($k,$info)){
+ $info[$k]=$v;
+ }
+ }
+
+ }
+ }
+
+ }
+ return $info;
+}}